From: Robert Klemme Date: 2009-12-11T02:23:35+09:00 Subject: Re: human-readable listing of array elements 2009/12/10 Aldric Giacomoni : > Marnen Laibow-Koser wrote: >> >> Yes.  case won't handle <= conditions AFAIK. > > That is a very good point, though it does handle ranges, so "case 0..1" > would fit this particular scenario. > Your elsif statement is probably better suited here though. That point is not exactly true: while it doesn't out of the box, it can easily be made to: irb(main):001:0> ONE_OR_LESS = lambda {|n| n <= 1} => # irb(main):002:0> class < nil irb(main):003:0> 5.times {|i| case i; when ONE_OR_LESS then puts "yow!" else puts "nah" end} yow! yow! nah nah nah => 5 irb(main):004:0> Apart from that, the length of an Array can as a minimum become only 0 so the same test can be done as case array.size when 0,1 # <= 1 ... when ... end Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/