On 10/4/06, James Edward Gray II <james / grayproductions.net> wrote: > 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 His example is more strict: it will match only for Object object, while yours will match any Object. (in other words, the OP checks for identity, while you check for class membership)