I want to change a value of a two dimensional array.
This is the array:
class Test
def initialize
@single = [1,2,3,4,5,6,7,8,9,10]
@double = [@single, @single, @single, @single]
end
def changeValue i, j
@double[i][j] = nil
end
def showDouble
return @double
end
end
I want to change a value in the double array (the two dimensional array). If I want to change the value of 9 in the first array, then I should do something like this:
test = Test.new
test.changeValue 0, 8
puts test.showDouble
When I do this, then the value of 9 is in every array nil. I only want to change it in one array. Any help is welcome! :)
single) in all elements of the the double array, changing the contents ofsinglein one row will change it in other rows as well (since it's really the same object).