From: John W Higgins Date: 2010-11-12T13:43:27+09:00 Subject: Re: Scheme's (cond ((assertion) (value))...(else (value))) statement implemented in ruby? --000e0cd4030e208f770494d3bb9c Content-Type: text/plain; charset=ISO-8859-1 Good Morning, On Thu, Nov 11, 2010 at 8:25 PM, timr wrote: > On Nov 11, 5:51 pm, Clifford Heath wrote: > > Case interrogates a single variable for its state--whether it falls in > a certain range, or is equal to such and such a value. The cond > statement is much more flexible, in that each assertion can be > completely unrelated to the other assertions--i.e. they can cover more > than the state of a single variable. > Nope, well sort of nope - you are right that it checks against a single variable but you are missing the trick. However the default "variable" for case is true and there are lots of options outside of the default as well. As an example x = 1 y = 2 case when x == 2 then puts 'x' when y == 2 then puts 'y' end That outputs a nice shiny "y" or x = 1 y = 2 case false when x == 2 then puts 'x' when y == 2 then puts 'y' end This outputs an even shiner "x" And even nicer x = 1 y = 2 case 2 when x then puts 'x' when y then puts 'y' end A nice shiny 'y' pops up on the screen John --000e0cd4030e208f770494d3bb9c--