I am relatively new to Ruby, but I am trying to catch a variable for later use.
Example:
x = [1,2,3]
y = x
y.reverse!
How do I get the original value of x back? It looks like x got changed when I changed y. Basically I need to catch and hold a variable value while altering a copy of it.
Many thanks!
AlanR
You need to use
.dupto create a clone of x.