Skip to content
Permalink
Browse files

Add Map.STORE(\keys,\values)

Another way of creating a Map 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 faa19ab commit cf5c8a099ef231b170e7cddf28d22f8ef08b0e88
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/core/Map.pm6
@@ -412,6 +412,20 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP
)
)
}
multi method STORE(Map:D: \keys, \values, :$INITIALIZE!) {
my \iterkeys := keys.iterator;
my \itervalues := values.iterator;
my \storage := $!storage := nqp::hash;
nqp::until(
nqp::eqaddr((my \key := iterkeys.pull-one),IterationEnd),
nqp::bindkey(
storage,
nqp::if(nqp::istype(key,Str),key,key.Str),
nqp::decont(itervalues.pull-one)
)
);
self
}
multi method STORE(Map:D: |) { X::Assignment::RO.new(value => self).throw }

method Capture(Map:D:) {

0 comments on commit cf5c8a0

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