> Am 31.10.2016 um 15:59 schrieb p...@highoctane.be:
> 
> but you should use myCollection ifEmpty: [ ... ]
> 
Why? 

Norbert

> Phil
> 
> On Mon, Oct 31, 2016 at 3:25 PM, Sven Van Caekenberghe <s...@stfx.eu 
> <mailto:s...@stfx.eu>> wrote:
> myCollection isEmpty ifTrue: [ self inform: 'The collection is empty' ].
> 
> First #isEmpty is sent to myCollection which results in either true or false 
> as value.
> 
> Then #ifTrue: is sent to this value.
> 
> Now, if the value was true (the sole instance of class True), the code in 
> True>>#ifTrue: is executed, which will evaluate the block by sending it 
> #value. If the value was false, the code in False>>#ifTrue: is executed, and 
> nil is returned and the block is not executed.
> 
> Like others said, it is just polymorphism at work.
> 
> (And yes, the compiler optimises some of this logic a bit, but the effect is 
> the same).
> 
> > On 31 Oct 2016, at 14:58, CodeDmitry <dimamakh...@gmail.com 
> > <mailto:dimamakh...@gmail.com>> wrote:
> >
> > But still, how is the actual argument "alternativeBlock" passed to the
> > True/False from a Boolean?
> >
> > The message does not cache the message inside itself before passing the
> > message, and it does not pass the alternative block along with the message.
> >
> >
> >
> > --
> > View this message in context: 
> > http://forum.world.st/How-does-Boolean-ifTrue-work-tp4920873p4920886.html 
> > <http://forum.world.st/How-does-Boolean-ifTrue-work-tp4920873p4920886.html>
> > Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
> >
> 
> 
> 
> 

Reply via email to