Skip to content

Instantly share code, notes, and snippets.

@jbarros35
Created April 16, 2018 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbarros35/6ee30b24de0ceebc79330ef8945e39b1 to your computer and use it in GitHub Desktop.
Save jbarros35/6ee30b24de0ceebc79330ef8945e39b1 to your computer and use it in GitHub Desktop.
Autoclosure Swift
var customersInLine = ["Alex", "Ewa", "Barry", "Daniella"]
print(customersInLine.remove(at:0)) // Alex
func serve(customer : @autoclosure () -> String) {
print("serving customer \(customer())")
}
serve(customer: customersInLine.remove(at:0)) // Ewa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment