KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to initialize a Hash of Arrays such as @my_hash = Hash.new(Array.new) so that I can: @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"] The problem is that any new hash key also return ["in the street", "at home"] @my_hash["bye"] => ["in the street", "at home"] @my_hash["xxx"] => ["in the street", "at home"] !!!??? What am I doing wrong what would be the correct way to initialize a Hash of Arrays?
Tags (comma-separated)
Save Edits
Cancel