From: jason joo Date: 2010-08-10T18:39:06+09:00 Subject: Re: hash --000e0cd2281e7125c7048d74e7b3 Content-Type: text/plain; charset=ISO-8859-1 actually u just need a method to put value in and return the overwrite value, don't u? so in a usual way u can write a Hash class to redefine its []= method to acheive that 2010/8/10 Jake Jarvis > On 10.08.2010 11:18, wrote Peter Hickman: > > The Ruby hash is not a Java HashMap > > > > x["key"] = "value_1" > > x["key"] = "value_2" > > > > puts x["key"] => "value_2" > > > > The best you can do is: > > 1) Create a HashMap class for Ruby, a very simple task > > 2) Use lists to store the values > > > > x["key"] = Array.new > > x["key"] << "value_1" > > x["key"] << "value_2" > > > > puts x["key"] => ["value_1", "value_2"] > > Why do that? > That's not how the given Java code behaves. > > -- > Jake Jarvis > > --000e0cd2281e7125c7048d74e7b3--