Hi -- On Tue, 1 Oct 2002, William Djaja Tjokroaminata wrote: > # ruby 1.6.7 (2002-03-01) [i686-linux] > s = "mutable" > arr = [s] > hash = { arr => "object" } > s.upcase! > p hash[arr] #=> nil > > This is really surprising to me! Is this the expected behavior in > Ruby? Because in Python, using an array as a hash key is forbidden in the > first place (syntax error, I guess), while Ruby simply allows us to do so. > > Any idea, anyone? (I really thought before that the hash key were > actually just the object ID in Ruby.) ri Hash#rehash: hsh.rehash -> hsh ------------------------------------------------------------------------ Rebuilds the hash based on the current hash values for each key. If values of key objects have changed since they were inserted, this method will reindex hsh. If Hash#rehash is called while an iterator is traversing the hash, an IndexError will be raised in the iterator. a = [ "a", "b" ] c = [ "c", "d" ] h = { a => 100, c => 300 } h[a] #=> 100 a[0] = "z" h[a] #=> nil h.rehash #=> {["c", "d"]=>300, ["z", "b"]=>100} h[a] #=> 100 David -- David Alan Black | Register for RubyConf 2002! home: dblack / candle.superlink.net | November 1-3 work: blackdav / shu.edu | Seattle, WA, USA Web: http://pirate.shu.edu/~blackdav | http://www.rubyconf.com