[squeak-dev] The Inbox: Collections-ct.850.mcz

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Thu Aug 15 00:20:55 UTC 2019


Thank you for the hint! I was not aware of #gather:, so #collectAll: does not really add value. :)

________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Jakob Reschke <forums.jakob at resfarm.de>
Gesendet: Donnerstag, 15. August 2019 02:07:07
An: squeak-dev at lists.squeakfoundation.org
Betreff: Re: [squeak-dev] The Inbox: Collections-ct.850.mcz

I don't see why the elements of the receiver must be collections. The result of the block must be a collection. Do the results differ between the following two expressions?

    aCollection collectAll: [:each | ...].
    (aCollection gather: [:each | ...]) asSet.

Am Do., 15. Aug. 2019 um 00:57 Uhr schrieb <commits at source.squeak.org<mailto:commits at source.squeak.org>>:
A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-ct.850.mcz

==================== Summary ====================

Name: Collections-ct.850
Author: ct
Time: 15 August 2019, 12:57:02.047584 am
UUID: a8581084-5210-3747-8b96-791b0458f52f
Ancestors: Collections-fn.847

Add #collectAll:, which performs a collector on each simply nested element

=============== Diff against Collections-fn.847 ===============

Item was added:
+ ----- Method: Collection>>collectAll: (in category 'enumerating') -----
+ collectAll: aBlock
+       "Loop over all elements of the receiver which must be collections
+       and for each simply nested element, evaluate aBlock. Collect the
+       resulting values into a set. Return the set."
+
+       | result |
+       result := Set new.
+       self
+               collect: aBlock
+               thenDo: [:collection | result addAll: collection].
+       ^ result!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190815/d8c19d43/attachment-0001.html>


More information about the Squeak-dev mailing list