Where would you put the return?

Stephen Pair stephen at pairhome.net
Mon May 19 18:55:18 UTC 2003


Andreas Raab wrote:

>Hi Benoit,
>
>In most cases I prefer the first version with explicit returns as it tells
>the reader what exactly is being returned. I find it *terribly* problematic
>to see code like
>
>	^foo = bar ifTrue:[42]
>
>as it doesn't tell me what is being returned if it's false (and no it does
>not return 'self' it returns 'nil' - ho hum...). So in this sense I find
>explicit returns *much* more expressive here and in many cases I would claim
>such changes to be an obfuscation rather than a 'cleanup' (as in: more
>readable, better to understand).
>
>Cheers,
>  - Andreas
>  
>
What do you think of lazy initializers written like:

something

    ^something ifNil: [something := 'initial value'].

- Stephen



More information about the Squeak-dev mailing list