[squeak-dev] Re: Why is Heap>>#species => Array?
Paolo Bonzini
bonzini at gnu.org
Sat Feb 23 08:07:06 UTC 2008
> However, some code used #species to answer a very different question:
> what class should I use to make a new collection like this one in a
> #collect: or a #select: ? Sometimes this was OK, but sometimes the
> answer was different from the answer that we got from #species. We
> decided to uniformly use two methods, emptyCopyOfSize: and
> emptyCopyOfSameSize , to generate the new collections.
> emptyCopyOfSameSize was implemented as
>
> ^ self emptyCopyOfSize: self size
This is what other Smalltalk usually call #copyEmpty and #copyEmpty:.
As I said, it works for everything except #reverse and #collect: for
which you can either use something like #copyEmptyForCollect, or resort
to #species.
Paolo
More information about the Squeak-dev
mailing list
|