From: Stefano Crocco Date: 2007-09-18T15:10:35+09:00 Subject: Re: how to use tuple as hash key Alle lunedì 17 settembre 2007, SpringFlowers AutumnMoon ha scritto: > h2 = {} > a = [0, 0] > > for i in 1..2 >   for j in 1..2 >     a[0] = i >     a[1] = j >     h2[a] = "ha" >   end > end > > p h2 > > ======================= > will produce: > >... > {[2, 2]=>"ha", [2, 2]=>"ha", [2, 2]=>"ha", [2, 2]=>"ha"} This happens because you don't call h2.rehash after modifying the array you use as key (look at the ri documentation for Hash#rehash for a longer explaination). If you insert the line h2.rehash after h2[a] = "ha" you'll get the expected behaviour. Stefano