a newbie question (disregard earlier message)
Hari Balaraman
hbalaram2 at yahoo.fr
Thu Jan 10 06:52:19 UTC 2002
Thanks Ned and Bob- I am once again on speaking terms with my trusty
mac(k)intosh.
Hari
On Wednesday, January 9, 2002, at 09:20 PM, Ned Konz wrote:
> On Wednesday 09 January 2002 02:47 pm, Hari Balaraman wrote:
>> Hi all,
>>
>> I'm attempting to learn Smalltalk and would like to post a small
>> question. I apologise in advance if this is is not the appropriate
>> forum
>> for basic questions. Is so please point me in the direction of the
>> relevant forum. Any assistance will be greatly appreciated.
>> Thanks much,
>>
>> Hari
>>
>> what follows is the method I wrote for the following problem: write an
>> array in which each element is the square of the corresponding element
>> in the receiver array. I cannot find out what I am doing wrong:
>>
>> arraySquared
>>
>> |squarearray |
>>
>> squarearray := Array new: (self size).
>> 1 to self size
>> do: [:index | squarearray at: index put:((self at:
>> index)*(self at: index))].
>> ^ squarearray
>
> You should say instead:
>
> 1 to: self size
>
> (you forgot the : at the end of the to).
>
> Or you could just do this:
>
> arraySquared
> ^self collect: [ :ea | ea * ea ]
>
> --
> Ned Konz
> currently: Stanwood, WA
> email: ned at bike-nomad.com
> homepage: http://bike-nomad.com
>
More information about the Squeak-dev
mailing list
|