5

It may be silly but I haven't found a good solution in the documentation about how to initialize a fixed array, or multidimensional array on an easy way without iterating.

my @array[10] = [0,0,0,0,0,0,0,0,0,0];
my @grid[100;100]; 
Javi
  • 305
  • 2
  • 7

1 Answers1

7

I'd probably use the xx operator. Something like this :

my @array[10] = 0 xx 10;
my @grid[100;100] = [0 xx 100] xx 100;
Elizabeth Mattijsen
  • 25,654
  • 3
  • 75
  • 105
Scimon Proctor
  • 4,558
  • 23
  • 22