From: Gavin Kistner Date: 2004-02-20T20:21:47+09:00 Subject: Can't case on class? The code below produces the following output: Class is ValidForm::OptionSet. Is it OK? true What about this: false WTF? 1 class ValidForm::Option 2 def field_tohtml(indentLevel=0) 3 puts "Class is #{@optionSet.class}." 4 puts "Is it OK? #{@optionSet.class==ValidForm::OptionSet}" 5 puts "What about this: #{@optionSet==ValidForm::OptionSet}" 6 case @optionSet.class 7 when ValidForm::OptionSet 8 #.... 9 10 when ValidForm::CheckboxSet 11 #.... 12 13 when ValidForm::RadioSet 14 #.... 15 16 else 17 puts 'WTF?' 18 end 19 end 20 end Thanks to memmove on #ruby-lang I found that if I change line #6 to: case @optionSet #no .class here then it works, but I don't understand why. Can someone explain why the former doesn't work? If this isn't an official bug, I call it a design flaw :) -- (-, /\ \/ / /\/