Operators

List repetition xx

Full

Repeat a value into a list — the list cousin of string repetition x.

xx repeats its left side into a list of that many copies. It's distinct from x (which repeats a string into a longer string): xx builds a list, x concatenates.

Building a list of copies #

say "ab" xx 3;
my @a = 0 xx 5;
say @a;
Output
(ab ab ab)
[0 0 0 0 0]

"ab" xx 3 is a three-element list (not the string "ababab" that x would give); 0 xx 5 is the idiom for a zero-filled array.

Notes #