There is the built in reduce function for this :let sum = arrayPoint.reduce(0, combine: +)You start with 0 (or any other value you want) and add all items in array.If you want the product :prod = arrayPoint.reduce(1,combine: *) // Here, need to start with 1You have other interesting functions on collections (map, filter, reduce); look hereh ttps://useyourloaf.com/blog/swift-guide-to-map-filter-reduce/
Topic:
Programming Languages
SubTopic:
Swift
Tags: