From: William Djaja Tjokroaminata Date: 2002-04-12T23:17:45+09:00 Subject: Why Object#class Is Inconsistent in "==" and "case"? Hi, I know that when I use the case statement, it is the "===" operator that is actually being used. However, the behavior with respect to Object#class is so inconsistent between "==" and "===". For example, module MyModule class MyClass end obj = MyClass.new puts "Using == it is OK" if obj.class == MyClass case obj.class when MyClass puts "Using case it is OK too" when MyModule::MyClass puts "Using case has to use the module name" else puts "The class name is #{obj.class}" end case obj.class.name when 'MyModule::MyClass' puts "Using case has to use the module and class names" end end So when I am using "==", it is very easy. However, when I use the case statement there are two extra work that I have to do: 1) Use the object class name instead of simply the object class. 2) Add the class module name instead of simply using the class name, even though I am inside the very same module. To me, this is a kind of violation of the Priciple of Least Surprise. Is there any particular reason why Ruby behaves like this? With this behavior, I am tempted to use the if...elsif...elsif...else construct when dealing with Object#class instead of the more elegant case statement. Regards, Bill