Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

Swift Closure as function parameter

// 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")
})
 
PREVIOUS NEXT
Tagged: #Swift #Closure #function #parameter
ADD COMMENT
Topic
Name
4+3 =