Re: Better ruby way for caseing on class?

From: ebeard [mailto:[email protected]]

Is there a better way?

Here’s one option:

[Kernel,String,Object].each do |klass|
case
when klass==Kernel
puts “I’m doing stuff with object Kernel”
when klass==String
puts “I’m doing stuff with object String”
when klass==Object
puts “I’m doing stuff with object Object”
end
end

yep that will work and looks like a reasonable alternative.