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

Levente Uzonyi leves at caesar.elte.hu
Wed Jun 14 20:10:01 UTC 2017


On Wed, 14 Jun 2017, commits at source.squeak.org wrote:

> Eliot Miranda uploaded a new version of Collections to project The Trunk:
> http://source.squeak.org/trunk/Collections-eem.756.mcz
>
> ==================== Summary ====================
>
> Name: Collections-eem.756
> Author: eem
> Time: 14 June 2017, 11:03:24.917631 am
> UUID: 8d7c03bc-1cdb-44c7-9173-10d50c0dae29
> Ancestors: Collections-eem.755
>
> Add SequenceableCollection>>withoutDuplicates for a more elegant fix to MailMessage>>to:
>
> =============== Diff against Collections-eem.755 ===============
>
> 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]]!

What a great opportunity to use #addNewElement::

 	^self select: [ :each | seen addNewElement: each ]

Levente


More information about the Squeak-dev mailing list