I wanted to copy one array into another, element by element, so that I
could edit the source data as necessary. I simultaneously changed a
source element using "strip!". The latter step corrupted the
copying. Without the bang operator, all works as expected.
This is not an earth-shattering problem. I'm just curious why it
doesn't work ... especially because it took me a good while to figure
out the cause of my app's failure.
strip! modifies the existing string (returning itself if a modification
occurred and nil if nothing was done), while strip does the modification
and returns a new string.
The strip! method isn't corrupting the copy. It's that the strip!
method returns nil if nothing was stripped from the string. That's
why you are getting nil for the second array element in the copy.