Bug/gotcha with Set>>collect:?

Henrik Gedenryd Henrik.Gedenryd at lucs.lu.se
Wed Jun 21 12:37:18 UTC 2000


I just encountered a real gotcha with Set>>collect, in that it returns its
result in a Set as well. Imagine collecting eg. the sizes of a set of
symbols. What you will get is in effect an occurrence set, since duplicates
are removed. 

The Blue Book says a collection of the same class should be returned by
collect:, so it seems consistent in this sense, but also, the size of the
result will not always be = to that of the original set, and this is not
consistent with the definition there.

And it doesn't seem logical to use a Set for the result here (unlike for
select:), as the collected items are not in general of the same kind as the
original set.

Shouldn't the result be an OrderedCollection?

I can hardly have been the first to encounter this (and yes, I know that I
can use "set asOrderedCollection" etc.).

Henrik






More information about the Squeak-dev mailing list