logo       

Re: class === class often false?: msg#01167

lang.ruby.general

Subject: Re: class === class often false?

Hi --

On Tue, 13 Aug 2002, Gavin Sinclair wrote:

> The main thing here is that when you type Bignum === x, or Comparable ===
> x, Ruby expects to be an Object. Now of course, everything is an Object,
> but it is their TYPE that is being inspected.
>
> So:
>
> - Bignum === Bignum: the RHS is an object of type Class, which does not
> feature in Bignum's ancestors; hence false.

I don't think that logic works -- it implies that if the RHS were of a
type which did feature in Bignum's ancestors, the test would be true.
But Bignum's ancestors include Object, and the RHS can't be an
arbitrary object :-)

I think it's more that the LHS has to be among the ancestors of the
type of the RHS. Bignum is not an ancestor of Class, so the result is
false.

> - Kernel === Kernel: everything has Kernel included in it, so x ===
> Kernel is always true.

Other way around :-) Kernel === x is always true.


David

--
David Alan Black
home: dblack@xxxxxxxxxxxxxxxxxxxx
work: blackdav@xxxxxxx
Web: http://pirate.shu.edu/~blackdav




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise