In the following, input_1
changes:
def method_1(a)
a << \"new value\"
end
input_1 = []
method_1(input_1)
input_1 #=> [\"new value\"]
Why
input_1
changes whereasinput_2
doesn't change?
The very simple answer to this question is that your premise is wrong. input_1
doesn't change. The object that input_1
references changes, but that is something completely different from input_1
. The name of a thing is not the same as the thing itself. (Outside of witchcraft.)