Joel VanderWerf
3/23/2006 5:28:00 PM
Robert Klemme wrote:
> Ross Bamford wrote:
>> On Thu, 2006-03-23 at 23:13 +0900, Une bévue wrote:
>
>>> the equality "===" returns false ???
>
> Adding to Ross' excellent explanation: it helps to *not* view "===" as
> an equality operator. Rather it's a general matching operator, whatever
> matching means in a certain context. For RX it will do an RX match, for
> class objects it will do the kind_of? check, for a range it will check
> include? etc. Btw, has anyone an idea why this does not apply to
> Enumerable?
>
>>> [1,2,3].include? 2
> => true
>>> [1,2,3] === 2
> => false
It would be nice, but then how would this work:
irb(main):001:0> case [1,2,3]
irb(main):002:1> when [1,2,3]
irb(main):003:1> puts "same array!"
irb(main):004:1> end
same array!
=> nil
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407