On 2020-06-03 01:25, Fernando Santagata wrote:
On Wed, Jun 3, 2020 at 10:07 AM ToddAndMargo via perl6-users <perl6-us...@perl.org <mailto:perl6-us...@perl.org>> wrote:

    Is there a way to write a methods as I would write
    a sub and avoiding the class thing?


I re-read the whole thread, but I still fail to understand what a "method as a sub, avoiding the class thing" is. Yet, I'm trying a mind-reading trick: when you say "method" perhaps you mean a sub you can call using a method call syntax.

Yes

If that's the case, then one may write something like this:

sub f($x) { $x² }

6.&f; # output: 36

Did the trick work?

--
Fernando Santagata


Indeed!  Thank you!

> sub f($x) { $x² }
&f
>
> 6.&f
36

I just have to add & in from of it.

-T

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to