Jump to content

Copy a string: Difference between revisions

→‎[[Python]]: Corrected "actual copy" code which doesn't, you know, actually copy.
No edit summary
(→‎[[Python]]: Corrected "actual copy" code which doesn't, you know, actually copy.)
Line 190:
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]]==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.