Created
April 21, 2016 20:18
-
-
Save MadcapJake/1873f1519528bf5c626bbd49ea6d7b3f 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
# No need for new/BUILD if you accept a longer instantiation | |
class FuzzyNum { | |
has Num $.i; | |
method gist { $!i.gist } | |
}; | |
# Must be multi, otherwise overwrites all + operators | |
multi sub infix:<+>(FuzzyNum $a, FuzzyNum $b) { | |
FuzzyNum.new(i => $a.i + $b.i + rand ** rand) | |
} | |
my FuzzyNum $a .= new(i => 1e0); | |
my FuzzyNum $b .= new(i => 1e0); | |
# Not sure why WHAT doesn't work here but it doesn't | |
say $a; | |
say $b; | |
say $a + $b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment