Swift lets us use functions just like any other type such as strings and integers. This means you can create a function and assign it to a variable, call that function using that variable, and even pass that function into other functions as parameters.
IMPORTANT: Closures let us wrap up some functionality in a single variable, then store that somewhere. We can also return it from a function, and store the closure somewhere else.
let driving = {
print("I'm driving in my car")
}
driving()
output
I'm driving in my car
Always declare data type of parameters.
let driving = { (place: String) in
print("I'm going to \(place) in my car")
}
driving("Karachi")
output
I'm going to Karachi in my car
this is how a function takes input