Array.zero()


Array.zero(OtherNumber, PreserveArrayStructure)

Replace all elements of the array by 0. If OtherNumber is given, that number is used instead.

The original array is replaced at the top level, unless PreserveArrayStructure is set to true.

1..10.zero()

0
0
0
0
0
0
0
0
0
0

1..10.zero(1..10)

1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10

[1,2,[3]].zero(3)

3
3
3

[1,2,[3]].zero(3,true)

3
3
3