Re: an elegant way to return a result
Posted by
Peter Uhnak on
Jun 30, 2015; 11:05am
URL: https://forum.world.st/an-elegant-way-to-return-a-result-tp4834837p4834841.html
No need to have both if you are returning the receiver.
^ something aMsg ifNotNil: [ aNotherResult ]
For example try printing these two lines
1 ifNotNil: [ true ]. "true"
nil ifNotNil: [ true ]. "nil"
If you are interested in the implementation details I highly recommend to look at the implementation.
ProtoObject>>ifNotNil: aBlock
and
UndefinedObject>>ifNotNil: aBlock.
Peter