The Trunk: Collections-mt.862.mcz

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

The Trunk: Collections-mt.862.mcz

commits-2
Marcel Taeumel uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-mt.862.mcz

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

Name: Collections-mt.862
Author: mt
Time: 19 November 2019, 11:10:22.542265 am
UUID: 892a021e-ac24-bd4f-84ba-12edb793c7a0
Ancestors: Collections-mt.861, Collections-ct.856

Merges Collections-ct.856. Harmonize all #detect: variations including their comments. Complements CollectionsTests-mt.327.

=============== Diff against Collections-mt.861 ===============

Item was changed:
  ----- Method: Collection>>detect: (in category 'enumerating') -----
  detect: aBlock
  "Evaluate aBlock with each of the receiver's elements as the argument.
+ Answer the first element for which aBlock evaluates to true. If there is
+ no such element, raise an error."
- Answer the first element for which aBlock evaluates to true."
 
+ ^ self
+ detect: aBlock
+ ifFound: [:element | element]
+ ifNone: [self errorNotFound: aBlock]!
- ^ self detect: aBlock ifNone: [self errorNotFound: aBlock]!

Item was added:
+ ----- Method: Collection>>detect:ifFound: (in category 'enumerating') -----
+ detect: aBlock ifFound: foundBlock
+ "Evaluate aBlock with each of the receiver's elements as the argument.  
+ Answer the first element for which aBlock evaluates to true. If there is
+ no such element, return nil."
+
+ ^ self
+ detect: aBlock
+ ifFound: foundBlock
+ ifNone: nil!

Item was changed:
  ----- Method: Collection>>detect:ifFound:ifNone: (in category 'enumerating') -----
  detect: aBlock ifFound: foundBlock ifNone: exceptionBlock
+ "Evaluate aBlock with each of the receiver's elements as the argument.
+ If there is any element for which aBlock evaluates to true, then evaluate
+ foundBlock with that element and answer the result of that foundBlock.
+ If aBlock does never evaluate to true, evaluate exceptionBlock, which
+ may or may not raise an error."
+
+ self do: [:each | (aBlock value: each) ifTrue: [^ foundBlock value: each]].
+ ^ exceptionBlock value
- "foundBlock takes one argument, the found object."
- self
- do: [ :element | (aBlock value: element) ifTrue: [ ^foundBlock value: element ] ].
- ^exceptionBlock value
  !

Item was changed:
  ----- Method: Collection>>detect:ifNone: (in category 'enumerating') -----
  detect: aBlock ifNone: exceptionBlock
  "Evaluate aBlock with each of the receiver's elements as the argument.  
+ Answer the first element for which aBlock evaluates to true. If there is
+ no such element, evaluate exceptionBlock."
- Answer the first element for which aBlock evaluates to true. If none  
- evaluate to true, then evaluate the argument, exceptionBlock."
 
+ ^ self
+ detect: aBlock
+ ifFound: [:element | element]
+ ifNone: exceptionBlock!
- self do: [:each | (aBlock value: each) ifTrue: [^ each]].
- ^ exceptionBlock value!