TrueClass === TrueClass

Hi all,
why is:

TrueClass === TrueClass # false
Object === Object # true

Documentation states that === method is used to provide meaningful
semantic in case statements. Can anyone explain me why some classes
returns false?

thnx,
Bojan M.

Bojan M. wrote:

Hi all,
why is:

TrueClass === TrueClass # false
Object === Object # true

Documentation states that === method is used to provide meaningful
semantic in case statements. Can anyone explain me why some classes
returns false?

=== returns true with one class if you ‘compare’ it to an instance of
the class:

irb(main):002:0> TrueClass == TrueClass
=> true
irb(main):003:0> TrueClass === TrueClass
=> false
irb(main):004:0> TrueClass === true
=> true

Cheers,

Vince

Vincent F. wrote:

Cheers,

Vince

Thanx Vince, just what I looked for.
Bojan

On 1/19/07, Vincent F. [email protected] wrote:

Cheers,
Ah - so Object === Object returns true because the second Object is an
instance of the first Object. How deceiving.

On 1/19/07, David C. [email protected] wrote:

semantic in case statements. Can anyone explain me why some classes
=> true

Cheers,

Ah - so Object === Object returns true because the second Object is an
instance of the first Object. How deceiving.

If you are looking for a language in which not everything is an object,
there are plenty around :wink:

On 1/20/07, David C. [email protected] wrote:

Object === Object # true
irb(main):002:0> TrueClass == TrueClass

If you are looking for a language in which not everything is an object,
there are plenty around :wink:

Oh, you misunderstand. Let me rephrase:

“How deliciously deceiving.”

I was not sure, but I thought that if you really did not realize what
was
going on I might give a hint :wink:
But of course you were, sorry for the noise.

Robert

On 1/20/07, Robert D. [email protected] wrote:

Documentation states that === method is used to provide meaningful
irb(main):004:0> TrueClass === true
=> true

Cheers,

Ah - so Object === Object returns true because the second Object is an
instance of the first Object. How deceiving.

If you are looking for a language in which not everything is an object,
there are plenty around :wink:

Oh, you misunderstand. Let me rephrase:

“How deliciously deceiving.”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs