From: Robert Dober Date: 2007-06-07T05:30:43+09:00 Subject: Re: === operator On 6/6/07, Jon Leighton wrote: > Hi, Maybe a more explicit notation helps > > >> {} === Hash {}.send(:===, Hash) > => false > >> case {} > >> when Hash then true when Hash.send(:===, {}) then true > >> end > => true > >> Hash === {} > => true > > Why is the first statement false when the second is true? I understand > case uses === to compare the objects? Perhaps it switches them round as > in the last statement? No the LHS is the receiver and the RHS is the first argument of the message. {}.send(:===, Hash) the === instance_method of Hash is called which is inherited from Object and basically means equality, hence false. Hash.send(:===, {}) the class method of Hash is called which is inherited from Class and means is_a? hence true. HTH Robert -- You see things; and you say Why? But I dream things that never were; and I say Why not? -- George Bernard Shaw