From: Mark Slagell Date: 2001-05-22T01:11:23+09:00 Subject: [ruby-talk:15492] Re: ranges & case ts spake: > > >>>>> "M" == Mark Slagell writes: > > M> We don't have open-ended ranges; is it possible to accurately express > M> this without resorting to if...elsif...end? > > If you don't want if ... elsif > > case > when p > 100 > "right" > when p > -100 > "center" > else > "left" > end > > Guy Decoux Ah. Hadn't thought of a naked-case like that. But since it doesn't factor the 'p' out, I'm not sure what it buys me. It just occurred to me that infinity could be used in a range. c = case p when (100 .. (+1.0/0)) then "right" when (-100 .. 100) then "center" when ((-1.0/0) .. -100) then "left" end