<div dir="ltr"><div>Hi timothy,</div><div><br></div><div>checkout Squeak's `Collection>>groupBy:`. There are some different semantics though: Pharo's version will preserve the relative order of the groups as they first appear in the collection and also return the same species of Collection nested in the dictionary, while Squeak disregards order of groups and always returns OrderedCollections.</div><div><br></div><div>Since both the naming (group*ed*By: since it returns a copy) and the properties of the output are more strict in Pharo's version, I would vote to copy the exact code from Pharo's version in the *Roassal-Squeak extension category to not break any assumptions from migrated code.</div><div><br></div><div>Best,</div><div>Tom<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Oct 25, 2020 at 12:31 PM gettimothy via Squeak-dev <<a href="mailto:squeak-dev@lists.squeakfoundation.org">squeak-dev@lists.squeakfoundation.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u><div><div style="font-family:Verdana,Arial,Helvetica,sans-serif;font-size:10pt"><div>First,<br></div><div><br></div><div>thank you for the 'gather' tip. It appears to work just fine.<br></div><div><br></div><div>Next pharo-ism is something named 'groupedBy:'<br></div><div><br></div><blockquote style="border:1px solid rgb(204,204,204);padding:7px;background-color:rgb(245,245,245)"><div><div>Collection >> groupedBy: aBlock<br></div><div>"Answer a dictionary whose keys are the result of evaluating aBlock for all my elements, and the value for each key is the selection of my elements that evaluated to that key. Uses species.<br></div><div><br></div><div>Example of use:<br></div><div>(#(1 2 3 4 5) groupedBy: [ :v | v odd ]) asString >>> 'an OrderedDictionary(true->#(1 3 5) false->#(2 4))'<br></div><div>"<br></div></div></blockquote><div><br><br>This looks like 'select:' to me.<br><br><br>any objections/insight much appreciated.<br><br>thx</div><div><br></div></div><br></div><br>
</blockquote></div>