From: Jeff Mitchell Date: 2004-07-07T17:04:27+09:00 Subject: Re: Class#=== has interesting results --- Charles Comstock wrote: > Why does this happen? > > class A > end > > A == A #1 => true > A === A #2 => false > > a = A.new > > a === A #3 => false > a == A #4 => false > A === a #5 => true > A == a #6 => false > > 1 makes sense, A is an A so therefor it should be true > 3 and 4 make sense since instance of A is not A and does not match A > 5 and 6 make sense in that A matches a, but A is not an a. > > But 2 doesn't make any sense to me, why doesn't an A match another A? > Is this just something that slipped through or is there a specific > reason for this? whatisit = case obj when Array "it's an array!" when Hash "it's a hash!" when Septuagenarian "it's a septuagenarian!" end $ ri Module#=== ------------------------------------------------------------- Module#=== mod === obj => true or false ------------------------------------------------------------------------ Case Equality---Returns +true+ if _anObject_ is an instance of _mod_ or one of _mod_'s descendents. Of limited use for modules, but can be used in +case+ statements to classify objects by class. __________________________________ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail