Wednesday 6 September 2017

Sum of elements in Swift array



let arr = [1,2,3,4,5,6,7,8,9,10]
var sumedArr = arr.reduce(0, {$0 + $1})
print(sumedArr)
The result will be: 55

No comments:

Post a Comment

Remove bottom line in navigation bar

navigationController ?. navigationBar . setBackgroundImage ( UIImage (), for: . any , barMetrics: . default )          navigat...