[Pkg] The Trunk: Collections-cmm.325.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Mar 5 03:48:13 UTC 2010

Chris Muller uploaded a new version of Collections to project The Trunk:

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

Name: Collections-cmm.325
Author: cmm
Time: 4 March 2010, 9:46:10.488 pm
UUID: 9e847ff1-32bd-4500-bc4a-8bf745d38e15
Ancestors: Collections-nice.324

Added Dictionary>>#at:ifPresent:ifAbsent:.  

When Dictionary already offers #at:ifPresent: and #at:ifAbsent: api, it is natural to expect, and better to write:

		at: key
		ifPresent: [ : found | .... ]
		ifAbsent: [ ... ]


		at: key
		ifPresent: [ : found | ... ])
			[ "absent"
			... ].
The new 5-line method relies on the legacy #at:ifPresent:.

=============== Diff against Collections-nice.324 ===============

Item was added:
+ ----- Method: Dictionary>>at:ifPresent:ifAbsent: (in category 'accessing') -----
+ at: key ifPresent: oneArgBlock ifAbsent: absentBlock
+ 	"Lookup the given key in the receiver. If it is present, answer the value of evaluating the oneArgBlock with the value associated with the key, otherwise answer the value of absentBlock."
+ 	^(self
+ 		at: key
+ 		ifPresent: oneArgBlock) ifNil: absentBlock!

More information about the Packages mailing list