[squeak-dev] Question about #caseOf:otherwise:

Stéphane Rollandin lecteur at zogotounga.net
Thu Aug 15 11:35:23 UTC 2019


Le 15/08/2019 à 10:32, Marcel Taeumel a écrit :
> Hi all!
> 
> Why isn't the following example possible?
> 
> aNumber caseOf: {
> *[:n | n even]* -> ['That is an even number.'].
> * [:n | n odd]* -> ['That is an odd number.'].
> }.
> 
> That is, why is the check "assoc key value = self" not configurable as 
> "(x := assoc key cull: self) == true or: [x = self]"? :-)
> 

The semantics would then change, because multiple tests could return 
true, and then it would have to be clear if only one case is taken into 
account, and which one (for example, the first), or if all cases are 
considered and then all associated blocks are evaluated (sequencially?).

So while nice, it seems to me that this proposal opens a can of worms...

My 2 cents,

Stef


More information about the Squeak-dev mailing list