// 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")
})