AW: [squeak-dev] IdentitySet>>collect:
Frank Lesser
frank-lesser at lesser-software.com
Wed Nov 26 23:34:39 UTC 2014
hmm, not convinced
(IdentitySet withAll: #(1 1.0)) collect: [:e| e asInteger ]
OrderedCollection(1 1 )
in LSWVST ( one-to-one ), you collect results of evaluating a block on
objects.
Frank
maybe I am wrong ...
-----Ursprüngliche Nachricht-----
Von: squeak-dev-bounces at lists.squeakfoundation.org
[mailto:squeak-dev-bounces at lists.squeakfoundation.org] Im Auftrag von David
T. Lewis
Gesendet: Donnerstag, 27. November 2014 00:11
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] IdentitySet>>collect:
On Wed, Nov 26, 2014 at 11:52:43PM +0100, Frank Lesser wrote:
> Hi Eliiot.
>
> I am not a native English - but collect: means collect IMO.
>
> so for every element deliver the result of evaluating the block. DOT
>
> interesting issue.
>
> Frank
I am a native American speaker, so your English is probably better than mine
;-)
I also was surprised by the result. But IdentitySet>>collect: is doing
the right thing in iterating over all the elements of the identity set:
| r |
r := Random new.
((IdentitySet withAll: #(1 2 3 1.0 2.0 3.0))
collect: [:e | r next]) size ==> 6
The confusing behavior is the result of answering a Set rather than
IdentitySet.
Eliot argues for answering an IdentitySet, Levente explains why this may
not be a good idea, and Eliot agrees that Levente's suggestion of using
the explicit #collect:as: is a satisfactory solution.
Dave
More information about the Squeak-dev
mailing list
|