[squeak-dev] Extending the functionality of caseOf: (was: #identityCaseOf:)
David T. Lewis
lewis at mail.msen.com
Sun Mar 28 23:32:26 UTC 2021
On Sun, Mar 28, 2021 at 05:26:42PM -0500, Chris Muller wrote:
>
> Here's the version using a temporary and existing API (with an added
> identity-check).
>
> result := self someComplexExpression.
> true caseOf:
> { [result=1] -> [self success].
> [result odd] -> [self processEvenValue: result-1].
> [ result == identityValue ] -> [self processSomethingElse ].
> [true] -> [self processEvenValue] }
>
> "true caseOf:" is my sneaky way to improve its flexibility. The suggested
> expansion of the API seems too dilute, not enough bang.
>
I really like the true caseOf: approach. It seems obvious now that you
point it out, but I never would have thought of it. Thanks :-)
Dave
More information about the Squeak-dev
mailing list
|