Maxime Guilbot schrieb:
>   def get_next
>     @indexes[0] = @indexes[0]*2
>     @indexes[1] = @indexes[1]*2
> 
>     @indexes
>   end

Use "@indexes.dup" istead of "@indexes" as the last Statement,...

>   def get_next_10
>     all = []
>     for i in 0..9
>       all << get_next
>     end
>     all
>   end
> end

...or "all << get_next.dup" instead of "all << get_next".

In both cases you will end up with:


pp d.get_next_10

=>

[[2, 2],
  [4, 4],
  [8, 8],
  [16, 16],
  [32, 32],
  [64, 64],
  [128, 128],
  [256, 256],
  [512, 512],
  [1024, 1024]]

The reason is, that you refer the same object in all Array positions othewise.

Wolfgang Ndasi-Donner