D
Dmitriy Makarov
how to repeat key's?
do you need a multivalue hash?how to repeat key's?
how to repeat key's?
{key => val1, val2, val3 ...}
2010/8/10 Peter Hickman said: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"]
2010/8/10 Jake Jarvis said: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.
Dmitriy said:
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.