[squeak-dev] The Trunk: Collections-ct.873.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Apr 7 21:01:27 UTC 2022


Christoph Thiede uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ct.873.mcz

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

Name: Collections-ct.873
Author: ct
Time: 31 January 2020, 11:53:15.549625 am
UUID: 431b3440-c343-7949-b8c4-c5627d640b36
Ancestors: Collections-nice.870

Extends #atLast: protocol on SequenceableCollection by implementing complete ifPresent:Absent: pattern.

See also Collections-ct.872.

=============== Diff against Collections-nice.870 ===============

Item was changed:
  ----- Method: SequenceableCollection>>atLast:ifAbsent: (in category 'accessing') -----
+ atLast: indexFromEnd ifAbsent: aBlock
- atLast: indexFromEnd ifAbsent: block
- 	"Return element at indexFromEnd from the last position.
- 	 atLast: 1 ifAbsent: [] returns the last element"
  
+ 	^ self
+ 		atLast: indexFromEnd
+ 		ifPresent: [:element | element]
+ 		ifAbsent: aBlock!
- 	^ self at: self size + 1 - indexFromEnd ifAbsent: block!

Item was added:
+ ----- Method: SequenceableCollection>>atLast:ifPresent: (in category 'accessing') -----
+ atLast: indexFromEnd ifPresent: elementBlock
+ 
+ 	^ self
+ 		at: self size + 1 - indexFromEnd
+ 		ifPresent: elementBlock
+ 		ifAbsent: []!

Item was added:
+ ----- Method: SequenceableCollection>>atLast:ifPresent:ifAbsent: (in category 'accessing') -----
+ atLast: indexFromEnd ifPresent: elementBlock ifAbsent: exceptionBlock
+ 	"Answer the value of elementBlock on the element at indexFromEnd from the last position. If the receiver does not contain an element at this position, answer the result of evaluating exceptionBlock."
+ 
+ 	^ self
+ 		at: self size + 1 - indexFromEnd
+ 		ifPresent: elementBlock
+ 		ifAbsent: exceptionBlock!



More information about the Squeak-dev mailing list