Raku Programming/Operator Overloading

From Wikibooks, open books for an open world
Jump to navigation Jump to search

There are only 5 types of operators: infix , prefix , postfix , circumfix and postcircumfix .

You can declare a new operator like this:

sub postfix:<!>(Int $n!) { [*] 1..$n }
say 5!; # prints 120

The above, as you can see, declares an operator '!' for calculating factorial of a Integer.