Skip to content

Commit

Permalink
infix:<eqv> for hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Jul 15, 2009
1 parent dfe8518 commit 10843c7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/setting/Operators.pm
Expand Up @@ -39,6 +39,15 @@ multi sub infix:<eqv>(Pair $a, Pair $b) {
$a.key eqv $b.key && $a.value eqv $b.value;
}

multi sub infix:<eqv>(Mapping $a, Mapping $b) {
return Bool::False if +$a != +$b;
for $a.kv -> $k, $v {
return Bool::False unless $b.exists($k);
return Bool::False unless $b.{$k} eqv $v;
}
return Bool::True;
}

multi sub infix:<eqv> ($a, $b) {
return Bool::False unless $a.WHAT === $b.WHAT;
die "infix:<eqv> is only implemented for certain special cases yet";
Expand Down

0 comments on commit 10843c7

Please sign in to comment.