From: Michael Neumann Date: 2004-12-14T02:45:22+09:00 Subject: Re: Hash freezes String keys are returns copy ts wrote: >>>>>>"M" == Michael Neumann writes: > > > > M> But why does this work: > > M> a = [] > M> hash[a] = "test" > M> a[0] = "1" > M> p hash.keys > M> # => returns [ ["1"] ] > > uln% cat b.rb > #!/usr/local/bin/ruby > a = [] > hash = { a => "test"} > a[0] = "1" > p hash[a] > uln% > > uln% b.rb > nil > uln% okay... but isn't it the same when using a String? a = "" hash = { a => "test" } a << "1" p hash[a] # => nil p hash.keys # => [""] while: a = [] hash = { a => "test" } a << "1" p hash[a] # => nil p hash.keys # => [["1"]] they behave differently. Regards, Michael