Skip to content
Permalink
Browse files

Add Hash.STORE(\keys,\values)

Another way of creating a Hash internally, taking 2 iterables: one with
keys and one with values, that are supposed to generate an equal number
of values.  To be used in hyper operations.
  • Loading branch information...
lizmat committed Nov 14, 2018
1 parent 80edefc commit faa19ab924203bc50b345f4179af4795d1f8c9a3
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/core/Hash.pm6
@@ -113,6 +113,16 @@ my class Hash { # declared in BOOTSTRAP

nqp::p6bindattrinvres(self,Map,'$!storage',$storage)
}
multi method STORE(Hash:D: \keys, \values) {
my \iterkeys := keys.iterator;
my \itervalues := values.iterator;
nqp::bindattr(self,Map,'$!storage',nqp::hash);
nqp::until(
nqp::eqaddr((my \key := iterkeys.pull-one),IterationEnd),
self.STORE_AT_KEY(key,itervalues.pull-one)
);
self
}

multi method ASSIGN-KEY(Hash:D: Str:D $key, Mu \assignval) is raw {
my \storage := nqp::getattr(self,Map,'$!storage');

0 comments on commit faa19ab

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