Copy a string: Difference between revisions

Content added Content deleted
No edit summary
(→‎[[Python]]: Corrected "actual copy" code which doesn't, you know, actually copy.)
Line 190: Line 190:
dst = src
dst = src


There's no way to actually copy a string in Python; all of the standard methods (the unconstrained index [:], copy.copy, copy.deepcopy) all return the same string object, since they're immutable.
To actually copy the string:
dst = src[:]


==[[Ruby]]==
==[[Ruby]]==