May you forgive me for this irrelevant thread but nonetheless, I need
your help.
I’m new at programming and recently I’ve faced with the problem
connected with the peculiarity of Ruby. Unlike many other languages, the
variables in it contain not the objects themselves but only links to
them, right?
So can you please explain me why do these two operations very close to
each other result in different ways, considering the fact that both a
and b contain the same link?
a=“13”
b=a
a=“12”
puts b --> 13
a=“13”
b=a
a[1]=“2”
puts b --> 12
To be more exact, in my program I need an array and a
variable=method(array). But when I call the method, the array itself
changes as well. How do I save the value of the array and get the
neccesary value of the variable at the same time?
P.S. And yes, I sought for solution in a guide but so far haven’t found
anything.