Resizing a string

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

Resizing a string

Nico de Boer
Resizing an empty string (try: '' resize: 10) gives me a walkback.
I was wondering if this is the correct behaviour,
or if it's a bug.

Thanks,

Nico


Reply | Threaded
Open this post in threaded view
|

Re: Resizing a string

Ian Bartholomew-3
Nico,

> Resizing an empty string (try: '' resize: 10) gives me a walkback.
> I was wondering if this is the correct behaviour,
> or if it's a bug.

I think you will find it is the intended behaviour. There used to be a lot
of problems caused by using statements like

WriteStream on: ''.

rather than

WriteStream on: String new

The first version has some rather undesirable results in the image as you
are mutating a constant. Rather than providing immutable Strings (as VA
Smalltalk does) a fix was added to force a walkback if an attempt was made
to mutate the empty string.

Ian