[Cuis-dev] unnecessary punctuation
Stephen Travis Pope
stephen at heaveneverywhere.com
Wed Jun 12 13:50:49 PDT 2024
I have to say that, to me, the “simplified” version looks quite unclear.
1. The standard teaching is that the arguments to ifTrue: et al. are always blocks, though it’s clear that the implementation uses value to evaluate blocks.
2. Having parens around the initial Boolean expression makes things clearer and is always to be preferred (less relying on the reader to know the precedence rules).
stp
--------
Stephen Travis Pope Ojai, California, USA

http://HeavenEverywhere.com
http://FASTLabInc.com
https://vimeo.com/user19434036/videos
http://heaveneverywhere.com/Reflections
> On Jun 12, 2024, at 6:56 AM, Mark Volkmann via Cuis-dev <cuis-dev at lists.cuis.st> wrote:
>
> I saw this example in a YouTube video about Smalltalk this morning:
>
> (2 > 3) ifTrue: ['Yes'] ifFalse: ['No']
>
> It seems to me that none of the parentheses or square brackets are needed here.
> The following works the same for me.
>
> 2 > 3 ifTrue: 'Yes' ifFalse: 'No'
>
> Is it true that keyword messages that take no-arg blocks can always take a literal value instead?
> It seems this works because the `Object` class defines the `value` method to just return `self`.
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240612/116fe195/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedGraphic.tiff
Type: image/tiff
Size: 2442 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240612/116fe195/attachment-0001.tiff>
More information about the Cuis-dev
mailing list