use of closures in swift code example
Example: closure swift
// The basic closure syntax is:
// { (parameter: Type) -> Type in <statements> }
//
// While closures can be assigned to a variable like in
// the example below, they become much more useful once
// they're passed into a function such as a list's `filter`
// method.
let closure = { (a: Int, b: Int) -> Int in return a * b }
print(closure(3, 6)) // 18
print(closure(10, 2)) // 20