Nope. Whenever you use (), the parser assumes a method call. sqr, inc and (sqr * inc) are not methods (but Proc objects), and all you can do is call _their_ methods, such as [].
Welcome to Ruby - Ruby has procs, blocks, lambdas, methods which are similar yet different.
Blocks aren't objects - when they are converted to objects, they become procs. Procs are like blocks and lambdas are like methods, but you can't call either of them with () syntax.
7 comments
[ 2.8 ms ] story [ 24.7 ms ] thread(sqr * inc)(5) ?
Blocks aren't objects - when they are converted to objects, they become procs. Procs are like blocks and lambdas are like methods, but you can't call either of them with () syntax.
And then there are multiple ways to call them:
Take your pick.https://github.com/stefanpenner/rebinder/blob/master/lib/reb...
My syntax was far more sarcastic and less legitimate, however. eg:
The fun bit is that this implementation doesn't actually use lambdas, but rather (Unbound)Method instances.