D
Damaris Fuentes
Hi you all,
I have the following code,where I have a hash whose entries are
initalized by an empty Array:
h = Hash.new(Array.new(0))
h["a"] << 0
h["b"] << 6
h["a"] << 5
h["b"] << 10
p h["a"]
p h["b"]
Both "p" prints the same: [0,6,5,10]
What am I doing wrong? (I want h["a"] to be [0,5] and h["b"]=[6,10]
I have the following code,where I have a hash whose entries are
initalized by an empty Array:
h = Hash.new(Array.new(0))
h["a"] << 0
h["b"] << 6
h["a"] << 5
h["b"] << 10
p h["a"]
p h["b"]
Both "p" prints the same: [0,6,5,10]
What am I doing wrong? (I want h["a"] to be [0,5] and h["b"]=[6,10]