[Newbies] Polymorphic or: with block argument
rainbowtwigs at gmail.com
Sun Sep 10 11:33:15 UTC 2017
I don't understand why Smalltalk doesn't allow me to have an or:
method that takes a block argument (except on Boolean). For example:
Set or: 1. ==> MNU as expected.
Set or: . ==> NonBooleanReceiver exception.
Set or: [:x | x] ==> Argument has too many arguments
Is it because the compiler specializes this to boolean when it sees
the or: [ ... ] syntax? Is this a tradeoff made for performance?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners