Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
move Hash.ACCEPTS to the setting, add more variants
Actually I'm not fully convinced that this is right approach because I don't
understand the magic with hash_ACCEPTS that the anonymous sub in
src/classes/Hash.pir:32-41 does, but the spectest didn't throw up any black
smoke.
  • Loading branch information
Moritz Lenz committed Jul 7, 2009
1 parent 7203e4b commit e249a62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/classes/Hash.pir
Expand Up @@ -25,7 +25,7 @@ src/classes/Hash.pir - Perl 6 Hash class and related functions
=cut

.namespace ['Perl6Hash']
.sub 'ACCEPTS' :method :subid('hash_ACCEPTS')
.sub '' :method :subid('hash_ACCEPTS')
.param pmc topic
.tailcall self.'contains'(topic)
.end
Expand Down
13 changes: 13 additions & 0 deletions src/setting/Hash.pm
@@ -1,4 +1,17 @@
class Hash is also {

multi method ACCEPTS(Regex $topic) {
any(@.keys) ~~ $topic;
}

multi method ACCEPTS(%topic) {
@.keys.sort eqv %topic.keys.sort;
}

multi method ACCEPTS($topic) {
$.contains($topic)
}

multi method invert () is export {
gather {
for @.pairs {
Expand Down

0 comments on commit e249a62

Please sign in to comment.