Basically

ifTrue: aBlock

is equivalent to:

ifTrue: aBlock ifFalse: [ ]

This is why ifTrue: answers nil if the receiver is false, because the
evaluation of an empty block answers nil ( [ ] is the same thing as [ nil ]
).

So you have to write it explicitly. The #and: version is probably the best
:-).

2015-04-02 9:12 GMT-07:00 Anne Etien <[email protected]>:

>
> Le 2 avr. 2015 à 18:02, Max Leske <[email protected]> a écrit :
>
>
> On 02 Apr 2015, at 17:31, Peter Uhnák <[email protected]> wrote:
>
> >       ^ (a=b) ifTrue: [ aBlockCheckingConditions].
>
>
> Boolean is still just an object, so you can use a cascade
> ^ (a=b)
>     ifTrue: [ aBlockCheckingConditions];
>     yourself
>
>
> But that will always return the the boolean from the first statement! If
> you want to return something from the conditions block you can’t do that.
>
> An alternative might be
>
> ^ a = b and: [ condition ]
>
>
> Yes!! Good idea.
> Thanks.
> Anne
>
>
>
> Peter
>
>
>
>

Reply via email to