Godot - Getting the Sum of an Array
This code example shows how to get the sum of an array in GDScript.
Use `reduce()
` to get the sum of an array.
It calls the specified Callable for each element in the array and accumulates the result.
var array = [5, 6, 7]
var sum = array.reduce(func(acc, num): return acc + num)
print(sum)
# 18