Perl 6 Perl 6 today #57

Operator overloading

Perl 6 allows custom operators:

sub postfix:<!> { [*] 1..$^n }

sub infix:<±>($a, $b) { $a + $b | $a - $b }

sub infix:<(c)>($who, $when) { "Copyright $when by $who" }

say 5!;             # 120
say 4 ± 3;          # 1 | 7
say "Pm" (c) 2009;  # "Copyright 2009 by Pm"
Copyright © 2009
http://www.pmichaud.com/2009/pres/