Squeak SmalltalkJoker Squeak Smalltalk : Language : prevnext Inlining Of If True

>     ifEmpty: aBlock
>         "Evaluate the block if I'm empty"
>         ^ self isEmpty ifTrue: aBlock
>
>
> It would be a tad less efficient,
> but (I think) more useful to say
>     ifEmpty: aBlock
>         self isEmpty ifTrue: [ ^ aBlock value ]

Without any doubt, the latter version is what it's meant to be. The 
former makes no sense (or rather: as much or as little sense as 
Object>>ifNil: would make returning nil when the receiver is non-nil).

Besides, the latter is *more* efficient. That's because ifTrue: gets 
inlined in this case but not in the former requiring a real send 
before activation of the block whereas in the second version (due to 
inlining) no send occurs for ifTrue: (look at the bytecodes to see the 
difference).