Roelof,

One technique to eliminating the use of #ifTrue:ifFalse: is to use double dispatching. There are some good examples of using double dispatching in Ralph Johnson's paper "ARITHMETIC AND DOUBLE DISPATCHING IN SMALLTALK-80"[1].  you should be able to get the basic idea by skimming the smalltalk code examples.

I used double dispatching fairly extensively in Metacello ...

In practice you may not eliminate all use of #ifTrue:ifFalse:, but double dispatching works quite well in places where you are tempted to do type checking...

Dale

[1] https://www.researchgate.net/publication/239578755_Arithmetic_and_double-_dispatching_in_smalltalk-80

On 11/27/18 8:40 AM, Roelof Wobben wrote:
Hello,

Yesterday I had a talk with luc frabresse about using if then.
He said if I understand it right, Its the best to not using a if then or a ifTrue/ifFalse.

Can anyone help me figure out how to rewrite this project so I will not use the ifTrue in the basement function.

my code so far can be found here : https://github.com/RoelofWobben/AOC2015

Roelof


Reply via email to