I am trying to follow the example in the Swift docs for a trailing closure.
This is the function:
func someFunctionThatTakesAClosure(closure: () -> Void) {
// function body goes here
print("we do something here and then go back")//does not print
}
And I call it here.
print("about to call function")//prints ok
someFunctionThatTakesAClosure(closure: {
print("we did what was in the function and can now do something else")//does not print
})
print("after calling function")//prints ok
The function, however, is not getting called. What is wrong with the above?
Here's the Apple example:
func someFunctionThatTakesAClosure(closure: () -> Void) { // function body goes here }
// Here's how you call this function without using a trailing closure:
someFunctionThatTakesAClosure(closure: { // closure's body goes here })