[squeak-dev] The Trunk: Kernel-mt.1422.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Nov 18 09:45:19 UTC 2021


Marcel Taeumel uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-mt.1422.mcz

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

Name: Kernel-mt.1422
Author: mt
Time: 18 November 2021, 10:45:17.4222 am
UUID: f0579623-5590-5e47-a848-0569491d6458
Ancestors: Kernel-mt.1421

Adds support for block-arg in caseOf's otherwise clause.

See discussions here:
- http://lists.squeakfoundation.org/pipermail/squeak-dev/2020-February/207261.html
- http://lists.squeakfoundation.org/pipermail/squeak-dev/2020-March/207963.html

=============== Diff against Kernel-mt.1421 ===============

Item was changed:
  ----- Method: Object>>caseOf:otherwise: (in category 'casing') -----
  caseOf: aBlockAssociationCollection otherwise: aBlock
+ 	"The elements of aBlockAssociationCollection are associations between blocks.  Answer the evaluated value of the first association in aBlockAssociationCollection whose evaluated key equals the receiver.  If no match is found, answer the result of evaluating aBlock."
- 	"The elements of aBlockAssociationCollection are associations between blocks.
- 	 Answer the evaluated value of the first association in aBlockAssociationCollection
- 	 whose evaluated key equals the receiver.  If no match is found, answer the result
- 	 of evaluating aBlock."
  
  	aBlockAssociationCollection associationsDo:
  		[:assoc | (assoc key value = self) ifTrue: [^assoc value value]].
+ 	^ aBlock cull: self
- 	^ aBlock value
  
  "| z | z := {[#a]->[1+1]. ['b' asSymbol]->[2+2]. [#c]->[3+3]}. #b caseOf: z otherwise: [0]"
  "| z | z := {[#a]->[1+1]. ['d' asSymbol]->[2+2]. [#c]->[3+3]}. #b caseOf: z otherwise: [0]"
  "The following are compiled in-line:"
  "#b caseOf: {[#a]->[1+1]. ['b' asSymbol]->[2+2]. [#c]->[3+3]} otherwise: [0]"
+ "#b caseOf: {[#a]->[1+1]. ['d' asSymbol]->[2+2]. [#c]->[3+3]} otherwise: [0]"
+ "#b caseOf: {[#a]->[1+1]. ['d' asSymbol]->[2+2]. [#c]->[3+3]} otherwise: [:x | x halt]"!
- "#b caseOf: {[#a]->[1+1]. ['d' asSymbol]->[2+2]. [#c]->[3+3]} otherwise: [0]"!



More information about the Squeak-dev mailing list