[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: duplicate keys in a Hash

Ross Bamford

3/22/2006 10:26:00 PM

On Thu, 2006-03-23 at 05:56 +0900, Brian Buckley wrote:
> In the code below it appears Ruby is permitting duplicate keys. What's
> happening?
> --Brian
>
> h = {}
> h[{}] = "test1" #key is an empty hash
> h[{}] = "test2" #2nd key is an empty hash -- two duplicate keys?
> h.size # 2
>
> {} == {} # => true empty hashes are equal

{}.eql? {}
# => false

{}.hash == {}.hash
# => false

I don't think Hash uses == at all.

--
Ross Bamford - rosco@roscopeco.REMOVE.co.uk