7.3. Closures as parameters
let drive = {
print("I am driving!")
}
let fly = {
print("I am taking a flight!")
}//taking a closure as the parameter 'how'
func travel(from source:String, to destination:String, how: ()->Void){
print("I need to travel from \(source) to \(destination).")
how()
}When closures accept parameters themselves and return values
Last updated