Let's say you have array of int and you want to total of all element.
Here is example,
let ints = 1...10 // [1,2,3,4,5,6,7,8,9,10]
print(ints.reduce(0, +))
After running this 2 lines of code you will get total of 1 to 10.
Here is example,
let ints = 1...10 // [1,2,3,4,5,6,7,8,9,10]
print(ints.reduce(0, +))
After running this 2 lines of code you will get total of 1 to 10.