Hi @VicLee92
I think most people struggle with closure and in the words of Paul
Don’t despair. Sometimes fighting to learn something makes it stick in your head better – there is no learning without struggle!
As @roosterboy
is correct what he say but you have to get it in your mind.
What I would suggest is go over the tutorial again but you will be using them alot in the future and more you use them the more clear the get.
You have a basic closures that is effectively creates a function without a name
let driving = {
print("I'm driving in my car")
}
This () -> Void
mean that you can pass in a function
func travel(method: () -> Void) { // <- pass in a function or closure
print("I'm getting ready to go.")
method() // <- this is where the function will be called
print("I arrived!")
}
so now when you 'run' the travel
function you have to pass in a function which in this case is driving
travel(method: driving)
PS change the action
to method
to show that the parameter name is a hint on what should be passed into function.
Nigel