Marcel Taeumel uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ct.1299.mcz==================== Summary ====================
Name: Kernel-ct.1299
Author: ct
Time: 16 February 2020, 4:26:42.224 pm
UUID: b1c9f40a-a7ea-9a4e-a502-268cb22592e7
Ancestors: Kernel-tonyg.1293
Refactor #valueSupplyingAnswers::
- Don't reinvent the wheel of Exception >> #pass
- Use #ifError:
See also
http://forum.world.st/The-Trunk-Kernel-mt-1283-mcz-td5107403.html.
=============== Diff against Kernel-tonyg.1293 ===============
Item was changed:
----- Method: BlockClosure>>valueSupplyingAnswers: (in category 'evaluating') -----
valueSupplyingAnswers: aListOfPairs
+ "Evaluate the receiver using a list of questions / answers that might be called upon to automatically respond to Object>>confirm: or FillInTheBlank requests"
- "evaluate the block using a list of questions / answers that might be called upon to
- automatically respond to Object>>confirm: or FillInTheBlank requests"
+ ^ self on: ProvideAnswerNotification do: [ :notification |
+ | caption |
+ caption := notification messageText withSeparatorsCompacted. "to remove new lines"
+ aListOfPairs
+ detect: [ :each |
+ caption = each first
+ or: [ (caption includesSubstring: each first caseSensitive: false)
+ or: [ (each first match: caption)
+ or: [ (caption respondsTo: #matchesRegex:)
+ and: [ [caption matchesRegex: each first] ifError: [false] ] ] ] ] ]
+ ifFound: [ :answer | notification resume: answer second ]
+ ifNone: [ notification pass ] ]!
- ^self
- on: ProvideAnswerNotification
- do: [ :notification |
- | caption |
- caption := notification messageText withSeparatorsCompacted. "to remove new lines"
- aListOfPairs
- detect: [ :each |
- caption = each first
- or: [ (caption includesSubstring: each first caseSensitive: false)
- or: [ (each first match: caption)
- or: [ (caption respondsTo: #matchesRegex:)
- and: [ [caption matchesRegex: each first] on: Error do: [false] ] ] ] ] ]
- ifFound: [ :answer | notification resume: answer second ]
- ifNone: [
- (ProvideAnswerNotification signal: notification messageText)
- ifNil: [ notification resume ]
- ifNotNil: [ :outerAnswer | notification resume: outerAnswer ] ] ]!