Skip to content

Commit

Permalink
Merge branch 'ng' of git@github.com:rakudo/rakudo into ng
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Feb 6, 2010
2 parents c0ae54d + 2d5c300 commit 654b789
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/core/Hash.pm
Expand Up @@ -15,4 +15,34 @@ role Hash is EnumMap {
done:
}
}

method !STORE(\$to_store) {
# We create a new storage hash, in case we are referenced in
# what is being stored.
pir::setattribute__vPsP(self, '$!storage', pir::new__Ps('Hash'));

# Work through the list, storing the things in it.
my $need_value = 0;
my $key;
for list($to_store) -> $cur {
if $need_value {
self{$key} = $cur;
$need_value = 0;
}
else {
given $cur {
# when Enum { ... }
# when EnumMap { ... }
default {
$key = $cur;
$need_value = 1;
}
}
}
}
if $need_value {
die('Odd number of elements found where hash expected');
}
self
}
}

0 comments on commit 654b789

Please sign in to comment.