Ruby: Array in Hash table disappears -
i have array of elements (temp
) place in hash (user_followings
) this:
user_followings[user.id] = temp
when temp.clear
after array added hash, elements in hash table, disappears.
what doing wrong?
after assignment, user_followings[user.id]
references same array
object temp
, if modify content of one(e.g, temp.clear
), other modified well.
if not want, try
user_followings[user.id] = temp.dup
Comments
Post a Comment