Permalink
Browse files

Make sure .Numeric is properly multied.

  • Loading branch information...
pmichaud committed Aug 3, 2011
1 parent 9a99a12 commit 120d3be93cba1f64c7c80b9dc5b25a64efcf93ab
Showing with 13 additions and 14 deletions.
  1. +3 −4 src/core/Bool.pm
  2. +1 −3 src/core/Enumeration.pm
  3. +2 −2 src/core/Iterable.pm
  4. +3 −2 src/core/List.pm
  5. +3 −2 src/core/Parcel.pm
  6. +1 −1 src/core/Str.pm
View
@@ -1,9 +1,8 @@
my class Bool {
- multi method Bool(Bool:D:) { self }
+ multi method Bool(Bool:D:) { self }
+ multi method Numeric(Bool:D:) { self ?? 1 !! 0 }
+ multi method Str(Bool:D:) { self ?? 'True' !! 'False' }
- multi method Str(Bool:D:) { self ?? 'True' !! 'False' }
-
- method Numeric() { self ?? 1 !! 0 }
method Int() { self ?? 1 !! 0 }
method pred() { Bool::False }
View
@@ -3,9 +3,7 @@ my role Enumeration {
has $.key;
has $.value;
- method Numeric(Enumeration:D:) {
- $!value.Numeric
- }
+ multi method Numeric(Enumeration:D:) { $!value.Numeric }
method enums() {
self.^enum_values
View
@@ -7,6 +7,6 @@ my class Iterable {
method Int() { self.elems }
method Num() { self.elems.Num }
- method Numeric() { self.elems }
- multi method Str(Iterable:D:) { self.list.Str }
+ multi method Numeric(Iterable:D:) { self.elems }
+ multi method Str(Iterable:D:) { self.list.Str }
}
View
@@ -15,9 +15,10 @@ class List does Positional {
method Bool() { self.gimme(1).Bool }
method Int() { self.elems }
- method Numeric() { self.elems }
method end() { self.elems - 1 }
- multi method Str(List:D:) { self.join(' ') }
+ multi method Numeric(List:D:) { self.elems }
+ multi method Str(List:D:) { self.join(' ') }
+
method fmt($format = '%s', $separator = ' ') {
self.map({ .fmt($format) }).join($separator);
}
View
@@ -3,9 +3,10 @@ my class Parcel does Positional {
# is Cool; # parent class
# has $!storage; # RPA of Parcel's elements
- multi method Str(Parcel:D:) { self.flat.Str }
+ multi method Numeric(Parcel:D:) { self.flat.elems }
+ multi method Str(Parcel:D:) { self.flat.Str }
multi method ACCEPTS(Parcel:D: $topic) { self.list.ACCEPTS($topic) }
- method Numeric() { self.flat.elems }
+
method Capture() { self } # XXX CHEAT CHEAT CHEAT
method flat() {
View
@@ -117,7 +117,7 @@ my class Str does Stringy {
$str;
}
- method Numeric(Str:D:) {
+ multi method Numeric(Str:D:) {
return nqp::p6box_n(pir::set__Ns('NaN')) if self eq 'NaN';
my str $str = nqp::unbox_s(self);
my int $eos = nqp::chars($str);

0 comments on commit 120d3be

Please sign in to comment.