Q: Ruby: Array in Hash table disappears I have an Array of elements (temp) that I place in a Hash (user_followings) like this:
user_followings[user.id] = temp

When I do temp.clear after the array are added to the Hash, the elements in the Hash table, also disappears.
What am I doing wrong?

A: After the assignment, user_followings[user.id] references to the same Array object as temp, if you modify the content of one(e.g, temp.clear), the other is modified as well.
If this is not what you want, try
user_followings[user.id] = temp.dup

