Skip to content
Permalink
Browse files

Provide return types to Duration methods

  • Loading branch information...
lizmat committed Jan 3, 2019
1 parent f976c85 commit cbc3e72e2bc49c4ad0d190ec0fdc1bb3e213c853
Showing with 13 additions and 13 deletions.
  1. +13 −13 src/core/Duration.pm6
@@ -13,38 +13,38 @@ my class Duration is Cool does Real {
)
}

method Bridge(Duration:D:) { $!tai.Num }
method Num (Duration:D:) { $!tai.Num }
method Rat (Duration:D:) { $!tai }
method narrow(Duration:D:) { $!tai.narrow }
method Bridge(Duration:D: --> Num:D) { $!tai.Num }
method Num (Duration:D: --> Num:D) { $!tai.Num }
method Rat (Duration:D: --> Rat:D) { $!tai }
method narrow(Duration:D: ) { $!tai.narrow }

multi method Str(Duration:D:) { ~$.tai }
multi method Str(Duration:D: --> Str:D) { ~$.tai }

multi method perl(Duration:D:) { "Duration.new({$.tai.perl})" }
multi method perl(Duration:D: --> Str:D) { "Duration.new({$.tai.perl})" }
}

multi sub prefix:<->(Duration:D $a) {
multi sub prefix:<->(Duration:D $a --> Duration:D) {
Duration.new: -$a.tai;
}

multi sub infix:<+>(Duration:D $a, Real $b) {
multi sub infix:<+>(Duration:D $a, Real $b --> Duration:D) {
Duration.new: $a.tai + $b;
}
multi sub infix:<+>(Real $a, Duration:D $b) {
multi sub infix:<+>(Real $a, Duration:D $b --> Duration:D) {
Duration.new: $a + $b.tai;
}
multi sub infix:<+>(Duration:D $a, Duration:D $b) {
multi sub infix:<+>(Duration:D $a, Duration:D $b --> Duration:D) {
Duration.new: $a.tai + $b.tai;
}

multi sub infix:<->(Duration:D $a, Real $b) {
multi sub infix:<->(Duration:D $a, Real $b --> Duration:D) {
Duration.new: $a.tai - $b;
}
multi sub infix:<->(Duration:D $a, Duration:D $b) {
multi sub infix:<->(Duration:D $a, Duration:D $b --> Duration:D) {
Duration.new: $a.tai - $b.tai;
}

multi sub infix:<%>(Duration:D $a, Real $b) {
multi sub infix:<%>(Duration:D $a, Real $b --> Duration:D) {
Duration.new: $a.tai % $b
}

0 comments on commit cbc3e72

Please sign in to comment.
You can’t perform that action at this time.