-
-
Save Ovid/fe0847a882ceda440271 to your computer and use it in GitHub Desktop.
Defining my operator failed
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
class Fahrenheit { | |
has Real $.temperature is required; | |
method infix:<+>(Fahrenheit:D $a, Fahrenheit:D $b) { | |
return Fahrenheit.new( temperature => $a.temperature + $b.temperature ); | |
} | |
} | |
my $t1 = Fahrenheit.new( temperature => 22 ); | |
my $t2 = Fahrenheit.new( temperature => 34 ); | |
say $t1 + $2; | |
# Cannot call Numeric(Fahrenheit: ); none of these signatures match: | |
# (Mu:U \v: *%_) | |
# in block <unit> at int.p6 line 11 |
As pointed out, $2
was a typo :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Per arnsholt, I've tried this, but it failed with the same error: