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

commits at source.squeak.org commits at source.squeak.org
Mon Nov 16 16:23:20 UTC 2020


A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-ct.921.mcz

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

Name: Collections-ct.921
Author: ct
Time: 16 November 2020, 5:22:33.980446 pm
UUID: 848dcc2a-ede6-534c-8244-80f5dd700148
Ancestors: Collections-mt.919

Adds convenience constructor for Dictionary.

Usage:
	Dictionary newFromKeys: 'wasd' values: {0@ -1. -1 at 0. 0 at 1. 1 at 0}

Reuploaded to replace Collections-ct.860, which can be moved into treated inbox. Thanks to everyone for the feedback!

(Ha, it took me less than a year to react on this feedback! Fortunately 2020 was a leap year ... ;-))

=============== Diff against Collections-mt.919 ===============

Item was added:
+ ----- Method: Dictionary class>>newFromKeys:values: (in category 'instance creation') -----
+ newFromKeys: keys values: values
+ 
+ 	| dictionary |
+ 	self assert: [keys size = values size].
+ 	dictionary := self new: keys size.
+ 	keys with: values do: [:key :value |
+ 		dictionary
+ 			at: key
+ 			ifPresent: [:ignored | self error: ('Duplicate key "{1}"' format: {key})]
+ 			ifAbsentPut: [value]].
+ 	^ dictionary!



More information about the Squeak-dev mailing list