Hi, easy example of what I need:
···
-------------------
klass = String
case klass
when String
puts "I'm String class"
else
puts "I'm nothing..."
end
-------------------
It produces "I'm nothing...". I understand why:
"case" matches the given object using "===", and:
String === String
=> false
while:
String === "a new string"
=> true
But in my case, klass variable holds a class rather than a class
instance. How could I use it within the above "case" statement? The
only way I've found is:
------------------------
klass = String
case klass.name
when "String"
puts "I'm String class"
else
puts "I'm nothing..."
end
-----------------------
But that is a *terrible* hack I hate. Any better suggestion?
Thanks a lot.
--
Iñaki Baz Castillo
<ibc@aliax.net>