Login  Register

Re: How does Boolean ifTrue work?

Posted by Thierry Goubier on Oct 31, 2016; 1:37pm
URL: https://forum.world.st/How-does-Boolean-ifTrue-work-tp4920873p4920881.html

Hi Dmitry,

you found it yourself, sort of!

Le 31/10/2016 à 14:25, CodeDmitry a écrit :
> Wait, so unlike JavaScript; True and False are actual singletons and
> ifTrue/ifFalse/ifTrue:ifFalse: uses visitor pattern to have the actual True
> or False handle the block rather than doing it themselves?

Yes, true and false are singletons (resp single instance of the True
class, False class).

No, this is not a visitor pattern, just polymorphism (True and False
have their own implementation of
ifTrue:/ifFalse:/ifTrue:ifFalse:/ifFalse:ifTrue:).

Regards,

Thierry