As a new Squeaker, I am slowly making my way through Mark's book on Squeak.
At the end of chapter 2, there are some exercises, specifically No. 3: Write a piece of workspace code [...] to do the following: (a) Replace all vowels in the string 'Squeak' with dashes. (b) Compute the average of a set of integers in an array.
I did this like so, but think it is more like "procedural-language speak' and not Smalltalk. Anyone have any more elegant solutions? I particularly do not like the use of the aCount variable.
aString := 'squeak'. aCount := 1. aString do: [:element | element isVowel ifTrue: [aString at: aCount put: $-]. "Could aString be self?" aCount := aCount +1].
anArray := #(12 14 16 18 20). aSum := 0. aCount := 0. anArray do: [:num | aSum := aSum + num. aCount := aCount +1]. anAverage := aSum / aCount.
Sorry for such a trivial start, but I really want to grok the OO way to do this.
Tom Porter