Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

can't use placeholders in a hash subscript

  • Loading branch information...
commit 1312772dad42e1027f282722fab120c14e8e8722 1 parent c32c4d0
@TimToady TimToady authored
Showing with 4 additions and 4 deletions.
  1. +4 −4 S32-list/sort.t
View
8 S32-list/sort.t
@@ -144,7 +144,7 @@ plan 32;
my %a = (4 => 'a', 1 => 'b', 2 => 'c', 5 => 'd', 3 => 'e');
my @e = (4, 1, 2, 5, 3);
- my @s = sort { %a{$^a} cmp %a{$^b} }, %a.keys;
+ my @s = sort -> $a, $b { %a{$a} cmp %a{$b} }, %a.keys;
is(@s, @e, '... sort keys by string value');
}
@@ -153,7 +153,7 @@ plan 32;
my %a = (4 => 'a', 1 => 'b', 2 => 'c', 5 => 'd', 3 => 'e');
my @e = (4, 1, 2, 5, 3);
- my @s = %a.keys.sort: { %a{$^a} cmp %a{$^b} };
+ my @s = %a.keys.sort: -> $a, $b { %a{$a} cmp %a{$b} };
is(@s, @e, '... sort keys by string value (using invocant form)');
}
@@ -162,7 +162,7 @@ plan 32;
my %a = ('a' => 4, 'b' => 1, 'c' => 2, 'd' => 5, 'e' => 3);
my @e = <b c e a d>;
- my @s = sort { %a{$^a} <=> %a{$^b} }, %a.keys;
+ my @s = sort -> $a, $b { %a{$a} <=> %a{$b} }, %a.keys;
is(@s, @e, '... sort keys by numeric value');
}
@@ -171,7 +171,7 @@ plan 32;
my %a = ('a' => 4, 'b' => 1, 'c' => 2, 'd' => 5, 'e' => 3);
my @e = <b c e a d>;
- my @s = %a.keys.sort: { %a{$^a} <=> %a{$^b} };
+ my @s = %a.keys.sort: -> $a, $b { %a{$a} <=> %a{$b} };
is(@s, @e, '... sort keys by numeric value (using invocant form)');
}
Please sign in to comment.
Something went wrong with that request. Please try again.