From: James Edward Gray II Date: 2006-10-05T01:17:34+09:00 Subject: Re: Better ruby way for caseing on class? On Oct 4, 2006, at 11:10 AM, ebeard wrote: > I currently do this: > > [Kernel,String,Object].each do |klass| > case klass.to_s > 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 > > > Is there a better way? 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. James Edward Gray II