I’m just noticing that some classes return true when testing
themselves with #===, while others return false. For instance:
(ruby 1.6.6 (2001-12-26) [i586-mswin32])
Bignum === Bignum
Kernel === Kernel
Object === Object
Comparable === Comparable
Just wondering if this behavior is intentional, and if so, why?
I’ll take a stab at this one.
If I’m wrong at any point, someone please correct me.
The === operator (method) may mean different things
depending on what class it belongs to. That’s no
When the receiver and the other operand (x === y)
are both classes, it is (I think) essentially the
same as saying:
So far, so good.
Note also that if a class includes a module, it
then has the “is a” relationship with that module,
and an included module shows up in the list of
ancestors. (Since a module is a kind of parent –
it’s like a limited form of inheritance.)
Then note that there is some circularity in Ruby’s
object paradigm. Everything is an object. Even the
class Class is an object. Note that these are
I have spent many hours lying in bed thinking about
I think the cases where you’re getting a “true” for
"klass === klass" are the ones where the circularity
is asserting itself.
For example: Kernel is-a Object, but Object is-a Kernel.
Or more indirectly: Kernel is-a Module is-a Object is-a
Kernel. There are probably other paths (through Class,
which is-a Module).
For the cases where you get false, I can’t see any
way of tracing back to oneself. For example, Bignum
is-a Object, or is-a Class, or is-a Kernel… but these
don’t ever lead back to Bignum.
----- Original Message -----
From: “Bill Kelly” email@example.com
To: “ruby-talk ML” firstname.lastname@example.org
Sent: Monday, August 12, 2002 6:52 PM
Subject: class === class often false?