Skip to content

Commit 09250ba

Browse files
authored
Idomatic-ize example
We don't post-increment hash keys to count things in Perl 6.
1 parent 2719b53 commit 09250ba

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

doc/Language/testing.pod6

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -402,17 +402,10 @@ use Test;
402402
plan 1;
403403
404404
sub count-chars(Str() $x) {
405-
my %chars;
406-
%chars{$_}++ for $x.comb;
407-
return %chars;
405+
$x.comb.Bag
408406
}
409-
my %expected =
410-
f => 1,
411-
l => 1,
412-
e => 3,
413-
c => 1,
414-
;
415-
is-deeply count-chars('fleece'), %expected, 'count-chars works on "fleece"';
407+
my $expected = bag <f l e e e c>;
408+
is-deeply count-chars('fleece'), $expected, 'count-chars works on "fleece"';
416409
=end code
417410
418411
B<Note:> for L<historical

0 commit comments

Comments
 (0)