Bug in nested iterations? (was: What is wrong with this?)
Joaquin Sitte
j.sitte at qut.edu.au
Thu May 26 08:56:18 UTC 2005
Dear Scott,
Many thanks for your help. Indeed it makes all the difference!
However it seems very subtle to me; in particular if you consider the
comment for the method from:to:put:
This is the comment:
"Put anObject in all indexes between startIndex
and endIndex. Very fast. Faster than to:do: for
more than 26 positions. Answer anObject"
Certainly tricky for a beginner.
Cheers
Joaquin
_____
From: Scott Wallace [mailto:scott.wallace at squeakland.org]
Sent: Thursday, 26 May 2005 15:12
To: Joaquin Sitte
Cc: squeak-dev at lists.squeakfoundation.org
Subject: Re: Bug in nested iterations? (was: What is wrong with this?)
At 2:15 PM +1000 5/26/05, Joaquin Sitte wrote:
This explains the behaviour. But this does not seem to be a terribly useful
way of doing things, at least not for my purpose. What is the proper way to
define a separate vector for every element in the map?
Hi Joaquin,
One simple way would be...
1 to: map size do:
[:i | map at: i put: (FloatArray new: 4)]
Cheers,
-- Scott
--------
>> map_ Som new: 30
>> map from: 1 to: map size put: (FloatArray new: 4).
> This sets it up so that only one FloatArray instance is created and
>it will be pointed to by all the 30 slots of 'map' object.
> (map first identityHash) = (map last identityHash)
>will be true.
This explains the behaviour. But this does not seem to be a terribly useful
way of doing things, at least not for my purpose. What is the proper way to
define a separate vector for every element in the map?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20050526/59f5e3f2/attachment.htm
More information about the Squeak-dev
mailing list
|