Posted by
jtuchel on
Oct 31, 2016; 1:58pm
URL: https://forum.world.st/How-does-Boolean-ifTrue-work-tp4920873p4920885.html
When I teach Smalltalk, this is one of the most beautiful exercises for
students.
Those who get it will love Smalltalk, those who don't often leave the
project soon ;-)
BTW: This is not a visitor or any other pattern, it really is just
Polymorphism at work and the reason why back in the 90ies, people said
if statements should be replaced by Polymorphism
Joachim
Am 31.10.16 um 14:17 schrieb CodeDmitry:
> 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?
>
>
>
>
> --
> 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.
>
>
--
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel mailto:
[hidden email]
Fliederweg 1
http://www.objektfabrik.deD-71640 Ludwigsburg
http://joachimtuchel.wordpress.comTelefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1