Created
May 7, 2016 22:06
-
-
Save ahalbert/b2714e33f15d6e2b3aa9944ef6c1867d to your computer and use it in GitHub Desktop.
This file contains hidden or 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; | |
ERROR: | |
Cannot call Numeric(Units::Unit: ); none of these signatures match: | |
(Mu:U \v: *%_) | |
in block <unit> at t/units.t line 12 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment