From: ebeard Date: 2006-10-06T03:35:06+09:00 Subject: Re: Better ruby way for caseing on class? I'm actually dealing with classes. not instances thereof. Gavin Kistner wrote: > From: James Edward Gray II [mailto:james@grayproductions.net] > > Sure. Drop the call to to_s() and the ' .. 's around the class > > names. Case calls ===() for the condition object and Class defines > > ===() to do what you expect here. > > Er...not quite, because (in his example) he has class objects, not > instances. > > [Kernel,String,Object].each do |klass| > case klass > when Kernel > puts "I'm doing stuff with object Kernel" > when String > puts "I'm doing stuff with object String" > when Object > puts "I'm doing stuff with object Object" > end > end > #=> I'm doing stuff with object Kernel > #=> I'm doing stuff with object Kernel > #=> I'm doing stuff with object Kernel > > > ebeard, in reality are you trying to handle class objects in your case > statement, or do you have instances of that class that you're trying to > determine the class of?