From: "Iñaki Baz Castillo" Date: 2011-08-15T00:47:46+09:00 Subject: How to use "case" to match class names? (=== not so funny) 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