I have a list of attributes. Each attribute will be setted as an empty array and i want to push elements to each array.
I figured out how to create a dynamic array with instance_variable_set but i couldn't push elements to it.
That's what i did:
attributes = ["eye","hair_color","hair_size","hair_type"]
i = 0
attributes.each do |a|
# Dynamic arrays are created, like: @eye = []
instance_variable_set("@#{a}", [])
# My attempt to push element
"@#{a}".push(i)
i += 1
end
How can i push an element to those dynamic arrays?