[squeak-dev] Dictionary>>collect: returning OrderedCollection?

K. K. Subramaniam subbukk at gmail.com
Fri Jun 13 10:37:56 UTC 2008


On Friday 13 Jun 2008 3:02:34 am 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.
Why so? #collect; is a closed operation on Collection, not on Dictionary. 
Unlike #select: or #reject:, it aggregates new objects (String in the 
example) generated from the values (Integer). Key associated with the value 
will not carry over to the new object automatically.

Bluebook describes collect: aBlock as:
<quote>
Evaluate the argument, aBlock, for each of the receiver's elements. Answer a 
new collection like that of the receiver containing the value returned by the 
block on each evaluation.
....
Messages inherited from the class Collection -- includes:, do: and other 
enumeration messages -- are applied to the *values* of the Dictionary. That 
is, these messages refer to the values of each association in the Dictionary, 
rather than to the keys or to the associations themselves.
</quote>

Subbu



More information about the Squeak-dev mailing list