Thanks for help. For anyone else, the following works.
sub infix:grew_by_to {...};
(32 grew_by_to 48).say;
sub infix:grew_by_to ($left, $right) {
return ($right/$left - 1) * 100 ~ '%';
};
Yuval Kogman wrote:
On Sun, Sep 17, 2006 at 16:35:39 +0100, Daniel Hulme wrote:
What am I doing
I tried to make a new growth operator.
The code was
(32 + 48).say;
sub infix:+ ($left,$right) {
return 100 * ($right/$left -1);
};
$pugs ./p6test.p6
returns with
50
But if I change the + character to (say) a cyrillic letter Д, I get the
following error:
$ pugs ./p6test.p6
***
What am I doing wrong?
Sounds like you need to define (or at least declare) the new operator
before you use it. Perl 6, like Perl 5 compiles with a single pass, so
when you are using your random operator, it hasn't yet read the
declaration further down the file.
It does its best to DTRT with