Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bring implementation (exists|delete)_key in line
  • Loading branch information
lizmat committed Aug 4, 2014
1 parent 59fee83 commit 1070a89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/EnumMap.pm
Expand Up @@ -45,10 +45,10 @@ my class EnumMap does Associative { # declared in BOOTSTRAP
&& nqp::existskey($!storage, nqp::unbox_s(key))
)
}
multi method exists_key(EnumMap:D: \key) {
multi method exists_key(EnumMap:D: \key as Str) {
nqp::p6bool(
nqp::defined($!storage)
&& nqp::existskey($!storage, nqp::unbox_s(key.Stringy))
&& nqp::existskey($!storage, nqp::unbox_s(key))
)
}

Expand Down
8 changes: 8 additions & 0 deletions src/core/Hash.pm
Expand Up @@ -136,6 +136,14 @@ my class Hash { # declared in BOOTSTRAP

proto method delete_key(|) { * }
multi method delete_key(Hash:U:) { Nil }
multi method delete_key(Str:D \key) {
my Mu $val = self.at_key(key);
nqp::deletekey(
nqp::getattr(self, EnumMap, '$!storage'),
nqp::unbox_s(key)
);
$val;
}
multi method delete_key(\key as Str) {
my Mu $val = self.at_key(key);
nqp::deletekey(
Expand Down

0 comments on commit 1070a89

Please sign in to comment.