Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add .Range "coercer" for Num/Rat types
  • Loading branch information
lizmat committed Mar 16, 2015
1 parent 1add79c commit 21f01b0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/Num.pm
Expand Up @@ -15,6 +15,7 @@ my class Num does Real { # declared in BOOTSTRAP
}
method Num() { self }
method Bridge(Num:D:) { self }
method Range(Num:U:) { Range.new(-Inf,Inf) }

method Int(Num:D:) {
nqp::isnanorinf(nqp::unbox_n(self)) ??
Expand Down
1 change: 1 addition & 0 deletions src/core/Rat.pm
Expand Up @@ -2,6 +2,7 @@
my class Rat is Cool does Rational[Int, Int] {
method Rat (Rat:D: Real $?) { self }
method FatRat(Rat:D: Real $?) { FatRat.new($.numerator, $.denominator); }
method Range(Rat:U:) { Range.new(-Inf,Inf) }
multi method perl(Rat:D:) {
my $d = $.denominator;
return $.numerator ~ '.0' if $d == 1;
Expand Down

0 comments on commit 21f01b0

Please sign in to comment.