From: Rob Biedenharn Date: 2008-05-24T02:51:50+09:00 Subject: Re: Module.===(X,X) is false On May 23, 2008, at 1:44 PM, calfeld@mac.com wrote: > Thanks for all the feedback. > > I'm aware of the usual use of Module.===, namely to check if an object > is an instance of a class or descendent of that class. > > My issue is not with when Module.=== is true, my issue is with a > specific example of when it is false. Namely, that, for a class (not > an instance) X, the following is true: > > (! (X === X)) && (X == X) > > This surprises me, and denies me the ability to compare a class (an > instance of Class) to its possible values (instances of Class) in a > case statement. > > Thanks again, > c. But what about X = Class? ;-) You can always use 'case' like an 'if' Foo = Class.new [Foo, Foo.new].each_with_index do |i,position| print "#{position}: " case when Foo == i puts 'i is the class Foo' when Foo === i puts 'i is an instance of Foo' end end -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com