Hi Traz,

On Sat, 8 Jan 2005 15:56:26 +0900, Traz <A.Reith / gmail.com> wrote:
> Hello all,
> I want to use some hash who have a hash key. But, i don't understand
> the hash key behaviour :
> 
> >> a={}
> => {}
> >> a[{1,2}]='ok'
> => "ok"
> >> a[{1,2}]
> => nil

I believe the answer is because each time you use {1,2} you are
creating a new Hash object with the same contents but a different
object identity:

irb(main):017:0> {1,2}.object_id
=> 22400644
irb(main):018:0> {1,2}.object_id
=> 22396300

Because Hash uses Object#eql? to test for equality it makes them
different keys and hence your example fails.

Hope this helps,

Matt

-- 
Matt Mower :: http://matt.blogs.it/