From: Andrei Beliankou on 10 Aug 2010 05:20 On Tue, 10 Aug 2010 17:37:09 +0900 Dmitriy Makarov <makarovx(a)gmail.com> wrote: > how to repeat key's? you can find an example solution in "The Ruby way." by Hal Fulton.
From: Dmitriy Makarov on 10 Aug 2010 05:21 > do you need a multivalue hash? > {key => val1, val2, val3 ...} Yes -- Posted via http://www.ruby-forum.com/.
From: jason joo on 10 Aug 2010 05:28 [Note: parts of this message were removed to make it a legal post.] another way is to make a patch to Hash object, put ur own rules in it and u will have a HashMap in ruby 2010/8/10 Peter Hickman <peterhickman386(a)googlemail.com> > 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"] > > On 10 August 2010 10:05, Dmitriy Makarov <makarovx(a)gmail.com> wrote: > >> what do u mean by 'repeat'? > > > > axample in java > > HashMap h=ne HashMap(); > > h.put("key","value_1"); > > h.put("key","value_2"); > > h.put("key","value_N"); > > > > how to made in ruby > > > > > > > > -- > > Posted via http://www.ruby-forum.com/. > > > > > >
From: Jake Jarvis on 10 Aug 2010 05:29 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
From: jason joo on 10 Aug 2010 05:39 [Note: parts of this message were removed to make it a legal post.] 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 <pig_in_shoes(a)yahoo.com> > 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 > >
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: [ANN] Detest 3.1.2 Next: Determining whether the running ruby is outdated? |