From: Tim Hunter Date: 2008-02-10T07:19:52+09:00 Subject: Re: Identifying Adam Akhtar wrote: > Farrel Lifson wrote: > >> Use a case statement: >> >> array.each do |x| >> case x >> when Array: do something >> when Integer: do something >> end >> end > > is > > when Array: do something > > a valid statement?? > > is > > if x == Array > > also a valid statement?? > > i was expecting having to use something like x.is_a as Stefano said. when Array: is valid in the context of a case expression. if x == Array is also valid, but will only be true if x is in fact Array, that is x = Array if x == Array # will be true For all other things, it will be false. Here's an online copy of the 1st Edition of _Programming_Ruby_, which will help answer these questions: http://www.ruby-doc.org/docs/ProgrammingRuby/ -- RMagick: http://rmagick.rubyforge.org/ RMagick 2: http://rmagick.rubyforge.org/rmagick2.html