Skip to content

Commit

Permalink
Let Hash use the new helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Apr 1, 2021
1 parent b188026 commit b7b6230
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/core.c/Hash.pm6
Expand Up @@ -218,7 +218,7 @@ my class Hash { # declared in BOOTSTRAP
method dynamic(Hash:D:) { nqp::hllbool($!descriptor.dynamic) }

method push(+values) {
fail X::Cannot::Lazy.new(:action<push>, :what(self.^name))
return self.fail-iterator-cannot-be-lazy('.push', self.^name)
if values.is-lazy;

my $previous;
Expand All @@ -245,7 +245,7 @@ my class Hash { # declared in BOOTSTRAP
}

method append(+values) {
fail X::Cannot::Lazy.new(:action<append>, :what(self.^name))
return self.fail-iterator-cannot-be-lazy('.append', self.^name)
if values.is-lazy;

my $previous;
Expand Down Expand Up @@ -273,7 +273,9 @@ my class Hash { # declared in BOOTSTRAP

proto method classify-list(|) {*}
multi method classify-list( &test, \list, :&as ) {
fail X::Cannot::Lazy.new(:action<classify>) if list.is-lazy;
return self.fail-iterator-cannot-be-lazy('classify')
if list.is-lazy;

my \iter = (nqp::istype(list, Iterable) ?? list !! list.list).iterator;
my $value := iter.pull-one;
unless $value =:= IterationEnd {
Expand Down Expand Up @@ -333,7 +335,9 @@ my class Hash { # declared in BOOTSTRAP

proto method categorize-list(|) {*}
multi method categorize-list( &test, \list, :&as ) {
fail X::Cannot::Lazy.new(:action<categorize>) if list.is-lazy;
return self.fail-iterator-cannot-be-lazy('.categorize')
if list.is-lazy;

my \iter = (nqp::istype(list, Iterable) ?? list !! list.list).iterator;
my $value := iter.pull-one;
unless $value =:= IterationEnd {
Expand Down

0 comments on commit b7b6230

Please sign in to comment.