From: benny Date: 2004-01-28T20:34:54+09:00 Subject: Re: newbee question about "missing" hash methods +, += and << > > > [dolio 04:59:10 ~]$ cat prac.rb > #!/usr/bin/ruby > > a = { 1 => 2 } > b = { a => 3 } > > p b > > b.delete a > > p b > > [dolio 04:59:14 ~]$ ./prac.rb > {{1=>2}=>3} > {} > > In your test, the { "foo" => "bar" } stored in the first hash wasn't the > same as the > one you tried to delete later (different objects/ids, same structure). > Hashes for > objects only have to be the same if #eql? returns true between them, and > that's > not necessarily the case for two structrurally identical hashes (it's > true only if they're > the same object). > > As I recall, in Python you can only use immutable things as keys to hashes. > However, in Java, for example, you can use any Object, whether it's a > String or > a Hashtable, so Ruby isn't alone. > > - Dan > ok, thank you for your explanation: I learn a lot from that! but when do we need such a thing? isn't it the contrast of the sense of an key and performance hungry? benny