I was playing with classes and adding a closure to an attribute.

I discovered that to call a closure on object I need `.()` rather than just `()`. See REPL below.

raku
Welcome to 𝐑𝐚𝐤𝐮𝐝𝐨™ v2020.12.
Implementing the 𝐑𝐚𝐤𝐮™ programming language v6.d.
Built on MoarVM version 2020.12.

To exit type 'exit' or '^D'
> class A { has &.f = -> { 'xyz' }}
(A)
> my A $a .=new
A.new(f => ->  { #`(Block|94272504746848) ... })
> say $a.f()
->  { #`(Block|94272504749656) ... }
> say $a.f.()
xyz
>


I was wondering whether it was intended for `()` to return something other than `.()`?

My first thought would be that `.()` would have the same syntactic sugar as `.[]` on an Array object.

I looked in the Documentation and in Classes found

&!callback();
inside class Task.

So I think there may be something a bit wrong. Or is this an artifact of REPL?

Reply via email to