Perl 6 Cool Perl 6 #79

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 © 2010
http://www.pmichaud.com/2010/pres/