// define a function
func grabLunch(search: () -> ()) {
…
// closure call
search()
}
// closure that accepts one parameter
let greetUser = { (name: String) in
print("Hey there, (name).")
}
// closure call
greetUser("Delilah")
// define a function and pass closure
func grabLunch(search: ()->()) {
print("Let's go out for lunch")
// closure call
search()
}
// pass closure as a parameter
grabLunch(search: {
print("Alfredo's Pizza: 2 miles away")
})
let driving = { (place: String) in
print("im going (place)")
}
driving("home")
() after first { and the after you make parameters write in
use driving("home") to call function.