From: Devin Mullins Date: 2007-06-14T22:21:40+09:00 Subject: Re: "case when" executes a symbol as method Francisco Laguna wrote: > The first just prints out the symbols turned to strings ("hello" or > "good_day", respectively), but the second one acrually executes the > hello and good_day methods and the case block has the return value of > the methods as its own value. Pretty cool, if you ask me. How come? Is > that something I can rely on, or something that might disappear, because > it's just some side-effect? Syntax/whitespace thing. No special meta-magic. > puts case greeting > when "Hello" :hello > when "Good Day" :good_day > end is > puts case greeting > when "Hello": hello > when "Good Day": good_day > end is > puts case greeting > when "Hello" then hello > when "Good Day" then good_day > end is > puts case greeting > when "Hello" > hello > when "Good Day" > good_day > end The equivalent of the first example would be: > puts case greeting > when "Hello": :hello > when "Good Day": :good_day > end