Permalink
Browse files

bring Hash.reverse up to date; test S32-hash/reverse.t

  • Loading branch information...
1 parent 7b2c47c commit 029aa517ebe4c44dcd34276c384511cf49914161 @moritz moritz committed Apr 9, 2009
Showing with 9 additions and 4 deletions.
  1. +8 −4 src/setting/Hash.pm
  2. +1 −0 t/spectest.data
View
12 src/setting/Hash.pm
@@ -1,8 +1,12 @@
class Hash is also {
- our Hash multi method reverse ( %hash: ) is export {
- my %result;
- (%result).{%hash.values} = %hash.keys;
- %result;
+ multi method reverse () is export {
+ gather {
+ for @.pairs {
+ for @( .value ) -> $i {
+ take ($i => .key)
+ }
+ }
+ }
}
multi method push (*@values) {
View
1 t/spectest.data
@@ -322,6 +322,7 @@ S32-hash/exists.t
S32-hash/keys_values.t
S32-hash/pairs.t
S32-hash/push.t
+S32-hash/reverse.t
S32-hash/slice.t
S32-list/end.t
S32-list/first.t

0 comments on commit 029aa51

Please sign in to comment.