[squeak-dev] The Trunk: Collections-eem.756.mcz
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
> 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.
Does this even work ?
Set does not preserve ordering.
Item was added:
+ ----- Method: SequenceableCollection>>withoutDuplicates (in category
+ "Answer a copy of the receiver that preserves order but eliminates
+ | 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...
More information about the Squeak-dev