[squeak-dev] Re: Dictionary>>collect: returning OrderedCollection?
Andreas Raab
andreas.raab at gmx.de
Fri Jun 13 07:29:33 UTC 2008
Thanks everyone. I filed a bug and a fix at
http://bugs.squeak.org/view.php?id=7095
BTW, Josh pointed out that ANSI agrees with that definition too:
5.7.2.6 Message Refinement: collect: transformer
Synopsis
Answer a new collection constructed by gathering the results of
evaluating transformer with each element of the receiver.
Definition: <collection>
For each element of the receiver, transformer is evaluated with the
element as the parameter. The results of these evaluations are collected
into a new collection. The elements are traversed in the order specified
by the #do: message for the receiver. Unless specifically refined, this
message is defined to answer an object conforming to the same protocol
as the receiver.
Refinement: <abstractDictionary>
Answer a new instance of the receiver's type with the same keys. For
each key of the answer, a new element is obtained by evaluating
transformer with the corresponding element of the receiver as the parameter.
Cheers,
- Andreas
Hans-Martin Mosner wrote:
> Andreas Raab schrieb:
>> Does anyone besides me consider this a bug? What does ANSI say about
>> this issue?
> I think that #collect: should be in line with #select: and #reject:
> which both return Dictionaries.
> One possible reason why #collect returns a different kind of collection
> is that for some base collections, the results of the block might not
> fit (for example, "aByteArray collect: [:x | x odd]" would raise an
> exception).
> Incidentally, VisualWorks behaves as you and I expect.
>
> Cheers,
> Hans-Martin
>
>
More information about the Squeak-dev
mailing list
|