The Inbox: Collections-ct.936.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Collections-ct.936.mcz

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

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

Name: Collections-ct.936
Author: ct
Time: 13 April 2021, 7:37:06.061492 pm
UUID: 155ef92e-af0e-1644-8109-126a6a0d4c50
Ancestors: Collections-mt.935

Proposal: Adds #indexOf:[startingAt:]ifPresent:[ifAbsent:] on SequenceableCollection.

See http://forum.world.st/BUG-Parser-does-not-detect-syntax-error-with-double-colon-tp5112572p5112854.html for a usage example.

=============== Diff against Collections-mt.935 ===============

Item was added:
+ ----- Method: SequenceableCollection>>indexOf:ifPresent: (in category 'accessing') -----
+ indexOf: anElement ifPresent: indexBlock
+
+ ^ self indexOf: anElement startingAt: 1 ifPresent: indexBlock!

Item was added:
+ ----- Method: SequenceableCollection>>indexOf:startingAt:ifPresent: (in category 'accessing') -----
+ indexOf: anElement startingAt: startIndex ifPresent: indexBlock
+
+ ^ self indexOf: anElement startingAt: startIndex ifPresent: indexBlock ifAbsent: [0]!

Item was added:
+ ----- Method: SequenceableCollection>>indexOf:startingAt:ifPresent:ifAbsent: (in category 'accessing') -----
+ indexOf: anElement startingAt: startIndex ifPresent: indexBlock ifAbsent: exceptionBlock
+
+ | index |
+ ^ (index := self indexOf: anElement startingAt: startIndex) = 0
+ ifFalse: [indexBlock value: index]
+ ifTrue: [exceptionBlock value]!