case .. when, === when, foo ===. , :
case foo
when 1 then "something"
when 2 then "something else"
when 3 then "another thing"
end
1 === foo, 2 === foo, 3 === foo, .
case .. when Procs when. Ruby, 1.9, proc === x proc.call(x). :
case foo
when Proc.new { foo.bar == 1 } then "something"
when Proc.new { foo.bar == 2 } then "something else"
when Proc.new { foo.baz == 3 } then "another thing"
end
, foo Procs, . , , ifs :
if foo.bar == 1
"something"
elsif foo.bar == 2
"something else"
elsif foo.baz == 3
"another thing"
end