iterate over string (UAX #29)

Viewed 130
say $s.substr($_, 1) for 0..^$s.chars

is the shortest I can find. Can you golf it to a reasonable size and avoid the repetition?

Perl 5 is shorter: say for split /\b{g}/, $s

1 Answers

The comb method without an argument will pick out every character, thus:

.say for $s.comb;

Will do what is desired (and is shorter than the Perl 5 version too :-)).

Related