Check out example codes for "let values = [3.0,6.0,9.0,1.0] let squares = values.map {$0 * $0} print(squares)". It will help you in understanding the concepts better.

Code Example 1

let values = [3.0,6.0,9.0,1.0]
let squares = values.map {$0 * $0}
print(squares)

Code Example 2

func sumSq(s: [Int]) -> Int {  return s.map{$0 * $0}.reduce(0, +)}

Learn ReactJs, React Native from akashmittal.com