-
-
Save Altai-man/f01dcc42134aff363d754cea7f423aa0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Robots { | |
class Robot { has $.power-level } | |
} | |
package Heroes { | |
class Hero { has $.level } | |
proto sub infix:<+>(|) is export {*} | |
multi sub infix:<+>(Hero $a, $b) { $a.level + $b } | |
multi sub infix:<+>($a, Hero $b) { $b.level + $a } | |
} | |
package Villains { | |
class Villain { has $.evil-power } | |
proto sub infix:<+>(|) is export {*} | |
multi sub infix:<+>(Villain $a, $b) { $a.evil-power + $b } | |
multi sub infix:<+>($a, Villain $b) { $b.evil-power + $a } | |
} | |
multi sub infix:<+>(Robots::Robot $a, $b) { $a.power-level + $b } | |
multi sub infix:<+>($a, Robots::Robot $b) { $b + $a } | |
say Robots::Robot.new(power-level => 3333) + Robots::Robot.new(power-level => 3333) + Heroes::Hero.new(level => 3333) + Villains::Villain.new(evil-power => 3333); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment