(Sorry for not finding a better title to my question. I’m not shure if
this has something to do with metaprogramming… I have hear about that,
but never had time to learn about it, so I don’t know what is
metaprogramming exactly)
Is there a way to do something like this?
arr = [ “red”, “green”, “yellow” ]
the following arrays should be incremented with the loop down
#here the loop that should increment the arrays
20.times do
arr.each { |color|
rand(60)
unless @color.include?(aleat) #this doesn’t work @color.push(aleat) # this doesn’t work…
end
}
end
…
…
Thanks in advance.
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto. http://es.voice.yahoo.com
hash.keys.each do |color|
array = hash[color] #do something here
end
But if you need to go through the colors in a particular order:
[ :red,:green,:blue ].each do |color|
etc.
#here the loop that should increment the arrays
20.times do
arr.each { |color|
rand(60)
unless @color.include?(aleat) #this doesn’t work @color.push(aleat) # this doesn’t work…
end
}
end
It always helps for you to say what you are trying to do, not just that
it
didn’t work.