How replace in String works

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

How replace in String works

GLASS mailing list
Hi,
GS 3.4.1

Why:
'123'  at: 3 put: $4; yourself.        "rise an exception"
'123' copy at: 3 put: $4; yourself   "works ok"

My problem was using replaceAll:with: but the "culprit" was at:put: in
Strings.

'123' copy isInvariant "answer false"
'123' isInvariant "answer true"

regards,
bruno



--
Sent from: http://forum.world.st/GLASS-f1460844.html
_______________________________________________
Glass mailing list
[hidden email]
https://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: How replace in String works

GLASS mailing list
Bruno,

In GemStone, literal strings and array are created invariant. As you
have discovered a copy of the string is not invariant, so if you are
created literal stringsĀ  that you intend to modify then you should do
the copy at creation time ...

Dale

On 1/15/20 8:56 AM, BrunoBB via Glass wrote:

> Hi,
> GS 3.4.1
>
> Why:
> '123'  at: 3 put: $4; yourself.        "rise an exception"
> '123' copy at: 3 put: $4; yourself   "works ok"
>
> My problem was using replaceAll:with: but the "culprit" was at:put: in
> Strings.
>
> '123' copy isInvariant "answer false"
> '123' isInvariant "answer true"
>
> regards,
> bruno
>
>
>
> --
> Sent from: http://forum.world.st/GLASS-f1460844.html
> _______________________________________________
> Glass mailing list
> [hidden email]
> https://lists.gemtalksystems.com/mailman/listinfo/glass
_______________________________________________
Glass mailing list
[hidden email]
https://lists.gemtalksystems.com/mailman/listinfo/glass