Copy a string: Difference between revisions

About copying vs referencing
(Objective C, various string copying options)
(About copying vs referencing)
Line 175:
[[Category:Python]]
'''Interpeter:''' Python 2.3, 2.4, 2.5
 
src = "Hello"
Since strings are immutable, this will not copy anything, just point dst to the same string:
dst = src
src = "Hello"
dst = src
 
To actually copy the string:
dst = src[:]
 
==[[Ruby]]==
Anonymous user