Bugs item #10776, was opened at 2007-05-11 21:52
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=10776&group_id=426

Category: None
Group: None
>Status: Closed
Resolution: None
Priority: 3
Submitted By: Darren Smith (flagitious)
Assigned to: Nobody (None)
Summary: Class#=== bug

Initial Comment:
Array===Array
-> false

Most classes return false with this usage.

This problem seems like it should occur fairly common in practice if you uses case statement to determine behavior based on class.

The bug occurred on: ruby 1.8.4 (2005-12-24) [powerpc-darwin7.9.0]
and: ruby 1.8.5 (2006-08-25) [x86_64-freebsd6.1]
(all versions tested)

----------------------------------------------------------------------

>Comment By: Yukihiro Matsumoto (matz)
Date: 2007-05-11 22:52

Message:
It's not a bug.  Class#=== works as "isinstanceof", so that 

  Array === Array

returns false since Array is a Class, not an array.

----------------------------------------------------------------------

Comment By: Jano Svitok (janek)
Date: 2007-05-11 22:50

Message:
This is not a bug.

See http://ruby-doc.org/core/classes/Module.html#M001689 for documentation on Module#=== (that is what you are calling).

In fact, what this does for Modules (and therefore for classes) is check if rhs is an instance of lhs. 

This is true only for Class, Module (Module class is a Class, so it is also a Module), Object (Object class is an instance of Object) and Kernel (Kernel module is instance of Module class, and it has Kernel module included) - in short, it is valid only for Class.ancestors. Therefore your statement about "Most classes" is indeed true ;-)

Once more, I suggest closing the bug.


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=10776&group_id=426