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

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -