Forked from ahalbert/gist:b2714e33f15d6e2b3aa9944ef6c1867d
Last active
May 7, 2016 22:10
-
-
Save AlexDaniel/429ed056c3791545824d2a1c139258fe 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
multi sub infix:<+>(Unit $x, Unit $y) { | |
if (not $x.isSameUnit($y)) {die "Units do not match.";} | |
return Unit.new(magnitude => $x.magnitude + $y.magnitude, units => $x.units); | |
} | |
my $a = Units::Unit.new(magnitude => 1.2, units => ("m" => 1)); | |
my $b = Units::Unit.new(magnitude => 5.0, units => ("m" => 1)); | |
say $a + $b; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment