looking for answers to exercises in Squeak book Ch 2.
Andrew C. Greenberg
werdna at mucow.com
Fri Apr 27 01:39:24 UTC 2001
> aString := 'squeak'.
> aCount := 1.
> aString do: [:element | element isVowel ifTrue:
> [aString at: aCount put: $-]. "Could aString be self?"
> aCount := aCount +1].
Solutions using collect: have been posted, these do the trick.
There is a problem in the preceding code that will not be apparent until
you actually use it in a program. This code is not only changing the
string, but also the literal 'sqeak' that was stored with the code. If
this block were executed repeatedly, this could lead to some pretty
obscure bugs.
More information about the Squeak-dev
mailing list
|