It has to do with how you construct your array. Your outer array contains 3 references to the same inner array. You need to force each inner array to be a separate object, which can be done like this: my_array = Array.new(3) { Array.new(3) }