I have a class like this:
class Tiles
attr_accessor :board
def initialize
@board = Array.new(4) { Array.new(4) { 0 } }
end
...
Later, I call this method:
def display_board
padded_board = @board.clone
padded_board.each_with_index do |row, x|
row.each_with_index do |item, y|
padded_board[x][y] = pad_number(item)
end
puts row.join ' '
end
end
Anytime I change padded_board
, @board
gets changed as well. I can't figure out why this is happening. Any ideas?