[squeak-dev] The Trunk: Collections-eem.756.mcz

Nicolai Hess nicolaihess at gmail.com
Fri Jun 16 11:05:11 UTC 2017


2017-06-16 12:38 GMT+02:00 Stéphane Rollandin <lecteur at zogotounga.net>:

>
>> Stéphane, can you live with ifMissingAdd: ?  Chris?
>>
>>
> Sure. Now "missing" seems to imply that something went wrong and an
> element is not there while it should (which is why I would prefer
> #ifAbsentAdd:).
>
> Plus, the name does not tell that a Boolean is returned (this apply to
> #ifAbsentAdd: too).
>
> So what about #ensurePresenceOf: ?
>
> I would expect this to return true if the element was *not* added, false
> otherwise, though.
>
>
> Stef
>
>
Does this even work ?
Set does not preserve ordering.

Item was added:
+ ----- Method: SequenceableCollection>>withoutDuplicates (in category
'copying') -----
+ withoutDuplicates
+       "Answer a copy of the receiver that preserves order but eliminates
any duplicates."
+       | seen |
+       seen := Set new: self size.
+       ^self select: [:each|
+                                 (seen includes: each)
+                                       ifTrue: [false]
+                                       ifFalse: [seen add: each. true]]!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170616/c973a214/attachment.html>


More information about the Squeak-dev mailing list