From: dblack@... Date: 2002-12-09T01:47:52+09:00 Subject: Re: elseif? Hi -- On Sun, 8 Dec 2002 dblack@candle.superlink.net wrote: > Hi -- > > On Sun, 8 Dec 2002 nobu.nokada@softhome.net wrote: > > > Hi, > > > > At Sun, 8 Dec 2002 06:18:52 +0900, > > Joel VanderWerf wrote: > > > x = 1.5 > > > > > case > > > when x < 0; puts "x < 0" > > > when 0 <= x && x < 1; puts "x in interval [0,1)" > > > when 1 <= x && x < 2; puts "x in interval [1,2)" > > > when 2 <= x; puts "x >= 2" > > > end > > > > If no expression after "case", "when" clause evaled as true > > will be executed. > > Yet more proof of my theory, which is that as you work on a problem in > Ruby, and it gets better and more idiomatic, code disappears from the > screen. Oh, and in case that wasn't enough proof: puts case when x < 0; "x < 0" when 0 <= x && x < 1; "x in interval [0,1)" when 1 <= x && x < 2; "x in interval [1,2)" when 2 <= x; "x >= 2" end David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav