When running this code:
def someFunction(someArray)
(0...(someArray.size)).each do |i| someArray[i] += 1 end
return someArray
end
array = [0, 1, 2]
someFunction(array) # => [1, 2, 3]
array # => [1, 2, 3]
array
is changed. In C, arrays are passed as pointers but I thought Ruby does't do 'pass by reference'. What is happening here and how can I make sure a method is not changing something outside it's scope?