Consider this new operator:
sub infix:<*++>(\num1, \num2) {
num1 * num2 + 1
}
say (2 + 1 *++ 3);
This code prints:
10
However, is it possible to control the precedence? Such it behaves like this:
say (2 + (1 *++ 3))
without needing to use parentheses
It is possible by is tighter
sub infix:<*++> (\num1, \num2) is tighter(&[+]) {
num1 * num2 + 1
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With