Login  Register

Re: How does Boolean ifTrue work?

Posted by CyrilFerlicot on Oct 31, 2016; 1:23pm
URL: https://forum.world.st/How-does-Boolean-ifTrue-work-tp4920873p4920875.html

On 31/10/2016 14:17, CodeDmitry wrote:

> I am looking at
>
> ifTrue: alternativeBlock
> "If the receiver is false (i.e., the condition is false), then the value is
> the
> false alternative, which is nil. Otherwise answer the result of evaluating
> the argument, alternativeBlock. Create an error notification if the
> receiver is nonBoolean. Execution does not actually reach here because
> the expression is compiled in-line."
>
> self subclassResponsibility
>
> In order to perform the block, ifTrue must somehow end up evaluating the
> block, but this code only sends a subclassResponsibility message to itself
> and implicitly returns itself.
>
> Where does the block actually get evaluated?
>
>
Hi!

Boolean is only an abstract class. You never manipulate a Boolean, you
manipulate True or False.

The #ifTrue: method works with a dispatch between True and False.

Try to check: `True browse` or `False browse` :)

>
>
> --
> View this message in context: http://forum.world.st/How-does-Boolean-ifTrue-work-tp4920873.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


--
Cyril Ferlicot

http://www.synectique.eu

2 rue Jacques Prévert 01,
59650 Villeneuve d'ascq France


signature.asc (817 bytes) Download Attachment