@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"]
! !! ??? ???
배열 해시를 초기화하는 올바른 방법은 무엇이 잘못 되었습니까?
관련 : http://stackoverflow.com/questions/190740/setting-ruby-hash-default-to-a-list – tokland