我正在try 初始化数组的散列,例如
@my_hash = Hash.new(Array.new)
这样我就可以:
@my_hash["hello"].push("in the street")
=> ["in the street"]
@my_hash["hello"].push("at home")
=> ["in the street", "at home"]
@my_hash["hello"]
=>["in the street", "at home"]
问题是,任何新的哈希键也会返回["in the street", "at home"]
@my_hash["bye"]
=> ["in the street", "at home"]
@my_hash["xxx"]
=> ["in the street", "at home"]
!!!???
我做错了什么初始化数组散列的正确方法是什么?