programming.nbk: Home | Index | Next Page: Ruby: Class | Previous Page: Ruby: Blocks
year = 2000 leap = case when year % 400 == 0: true when year % 100 == 0: false else year % 4 == 0 end puts leap # output is: true
The case statement returns the value of the last expression executed.
programming.nbk: Home | Index | Next Page: Ruby: Class | Previous Page: Ruby: Blocks
Notebook exported on Monday, 7 July 2008, 18:56:06 PM Eastern Daylight Time