Ruby on Rails - Randomize JSON variable and apply in Array

0

Well, I have a problem that is relatively simple, but that is ending with me.

I have an array of JSON objects. This array of objects will compose another array containing other n arrays.

So far so good. However, what happens is that with each iteration I randomize the "value" attribute and place the object in that new array. And when I see, at the end of the iterations, all objects have the same value (the last random).

Can anyone help me?

    
asked by anonymous 09.11.2015 / 22:42

1 answer

1

It turns out that you say it's only '=', try adding it with < and see what happens.

times << $parametros[populacaoInicial''].to_i
  

Or, link

arr = [1, 2, 3, 4]
arr.push(5) #=> [1, 2, 3, 4, 5]
arr << 6    #=> [1, 2, 3, 4, 5, 6]
    
17.12.2015 / 15:48