From: Brian Candler Date: 2009-06-02T19:46:53+09:00 Subject: Re: <, >, and ranges in a case statement. Max Williams wrote: > Wow, that's a lot more complicated than i thought. I think for the sake > of ease and readability i'd stick with doing a more longwinded version, > like > > category = case > when age < 12 : "child" > when (13..17).include? age : "minor" > when (18..24).include? age : "young ad*lt" > when (25..49).include? age : "ad*lt" > when (50..64).include? age : "middle aged" > when age > 65 : "senior" > else : "not an age" > end > > thanks for the insight though! If you want to allow for the possibility of fractional ages: when (13...18).include? age when (18...25).include? age when (18...50).include? age .. etc -- Posted via http://www.ruby-forum.com/.