its possible to completely or partly avoid a condition check . Instead you
can use a common name for a method for various objects , that method may
have different code for each object it belongs. This way you dont need to
check your data instead you send the message and you let the method itself
to execute the appropriate code for the approriate object( kind of data).

This also much more reasonable to read. It will depend however in your
particular situation. You can have also a chain of methods. Essentially we
talk here about objects that interact with each other by triggering methods
without the need for conditional checks since the method call is of the
same name but the code executed  depends on the receiver of the message /
messages.

It takes time to get used to this chain reaction message sending but I
think it really worth it because it produces far simpler code to read and
far more modular too.

On Thu, Apr 2, 2015 at 6:15 PM, 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:?
>
> The problem comes certainly because we don’t know that the ifTrueBlock
> will return a boolean.
>
> If you have prettier ideas, I am interested in.
>
> Anne
>

Reply via email to