Skip to content

Commit

Permalink
[PROBES] Use modern hash iteration semantics properly in %hash.kv
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoffrey Broadwell committed Nov 9, 2009
1 parent c980976 commit abc6bc0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions probes/hash-kv.nqp
Expand Up @@ -5,11 +5,12 @@
# TO USE:
# $ nqp hash-kv.nqp

# Hash.kv by pmichaud++ in http://nopaste.snit.ch/18559
# Original Hash.kv by pmichaud++ in http://nopaste.snit.ch/18559;
# updated to handle new-style hash iteration semantics
module Hash {
method kv () {
my @kv;
for self { @kv.push($_); @kv.push(self{$_}); }
for self { @kv.push($_.key); @kv.push($_.value); }
@kv;
}
}
Expand All @@ -21,5 +22,5 @@ my %hash;
%hash<c> := 3;

for %hash.kv -> $k, $v {
say(~$k ~ "\t" ~ $v);
say($k ~ "\t" ~ $v);
}

0 comments on commit abc6bc0

Please sign in to comment.