> On 02 Apr 2015, at 17:15, Anne Etien <[email protected]> wrote:
> 
> Hi,
> 
> I wanted to write a method that:
> - if (a = b) checks other conditions that are specified in the ifTrue block 
> and return this (boolean) value
> - returns false if (a!=b) 
> 
> So I wrote:
> myMethod
>       ^ (a=b) ifTrue: [ aBlockCheckingConditions].
> 
> However, when (a!=b) the method returns nil (since false ifTrue: [] returns 
> nil). So do you have an idea how I can do to express that or should I 
> mandatorily wrote also an ifFalse:?

I always use #ifTrue:ifFalse: in such situations, just to be explicit. It makes 
reading the code easier too.

> 
> The problem comes certainly because we don’t know that the ifTrueBlock will 
> return a boolean.

There’s been years of debate on this :)

> 
> If you have prettier ideas, I am interested in.
> 
> Anne

Cheers,
Max

Reply via email to