replaceIdentity:with: and Strings

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

replaceIdentity:with: and Strings

Stefan Schmiedl
What's the idea behind

str := '12345' copy.
str replaceIdentity: $1 with: $x.
str inspect

changing str to '12345x' instead of 'x2345' as the method documentation
led me to believe?

ArrayedCollection>>replaceIdentity: anObject with: newElement
  "If the receiver contains an identity match for anObject replace the
first with newElement,
  otherwise increase the size of the receiver, and append newElement.
Answer the index.
  This is a very useful method in many system support tasks (e.g. the
Dependency
  mechanism)"

If this is supposed to work, then String needs another implementation
of basicIdentityIndexOf:from:to:

s.