Copy a string: Difference between revisions

Content added Content deleted
(Objective C, various string copying options)
(About copying vs referencing)
Line 175: Line 175:
[[Category:Python]]
[[Category:Python]]
'''Interpeter:''' Python 2.3, 2.4, 2.5
'''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]]==
==[[Ruby]]==