Browse files

Update Array.new and List.new to be more robust.

  • Loading branch information...
1 parent e6459bc commit 3c225982386c67bf0077d6c32b6cbfdecbb31ea9 @pmichaud pmichaud committed Jun 26, 2011
Showing with 10 additions and 2 deletions.
  1. +4 −2 src/core/Array.pm
  2. +6 −0 src/core/List.pm
View
6 src/core/Array.pm
@@ -1,8 +1,10 @@
class Array {
# Has attributes and parent List declared in BOOTSTRAP.
- method new(*@values) {
- my @a = @values;
+ method new(|$) {
+ my Mu $args := pir::perl6_current_args_rpa__P();
+ nqp::shift($args);
+ nqp::p6list($args, self.WHAT, 1.Bool);
}
method at_pos($pos) {
View
6 src/core/List.pm
@@ -5,6 +5,12 @@ class List does Positional {
# has $!flattens; # true if this list flattens its parcels
# has $!nextiter; # iterator for generating remaining elements
+ method new(|$) {
+ my Mu $args := pir::perl6_current_args_rpa__P();
+ nqp::shift($args);
+ nqp::p6list($args, self.WHAT, Mu);
+ }
+
method Bool() { self.gimme(1).Bool }
method Int() { self.elems }
method Numeric() { self.elems }

0 comments on commit 3c22598

Please sign in to comment.