Gavin Kistner
10/4/2006 4:28:00 PM
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?