From: Hugh Sasse Staff Elec Eng Date: 2001-01-04T03:48:16+09:00 Subject: [ruby-talk:8582] Re: bug?? On Thu, 4 Jan 2001, Jean Michel wrote: > I don't understand the following behaviour: > > irb(main):015:0> a=Hash.new("") > {} Creates the new hash, and a single object <""> to return when an nonexistent element is accessed. > irb(main):016:0> a[1]<<"a" > "a" Access a nonexistent element -> "" append "a" to it : "" << "a" -> "a" > irb(main):017:0> a[1] > "a" Access a non existenet element. Get the one object back, as before, but you just modified it, so it is "a", not "" any more. > irb(main):018:0> a > {} You still haven't defined any keys for the hash yet, so there is nothing in it. > > Best regards, > Jean MICHEL > Hugh hgs@dmu.ac.uk