jashkenas--coffeescript/test/test_switch.coffee

32 lines
371 B
CoffeeScript
Raw Normal View History

num: 10
result: switch num
2009-12-29 04:08:02 +00:00
when 5 then false
when 'a'
true
true
false
when 10 then true
# Mid-switch comment with whitespace
# and multi line
2009-12-29 04:08:02 +00:00
when 11 then false
else false
puts result
2010-02-12 21:23:52 +00:00
func: (num) ->
switch num
when 2, 4, 6
true
when 1, 3, 5
false
else false
puts func(2)
puts func(6)
puts !func(3)
puts !func(8)