ARRAY::FILL
1g 2023-12-06 laplante@plcb.ca GOWEB/ARRAY — Fill Array with a Valuetitle: “ARRAY::FILL” version: “1g” date: 2023-12-06 author: “laplante@plcb.ca”
array::fill Fill Array with a Value
array::fill(variable, value[, deep: bool])
The fill
function replaces all elements in an array with the specified value.
deep
is true
(default), the function will work recursively and replace all values inside nested arrays.deep
is false
, only the top-level elements are replaced.res={{
a := [1,2,3];
fill(a, null);
a;
a = [ [1,2], [3,4], [5,6] ];
fill(a, "A");
a;
a = [ [1,2], [3,4], [5,6] ];
fill(a, deep:false, "A");
a;
}}.
Returns:
[null,null,null]
[["A","A"],["A","A"],["A","A"]]
["A","A","A"]
laplante@plcb.ca