Reputation: 161
While researching a separate issue, I came across this SO question: How to create generic closures in Swift
They have a function definition like this:
func saveWithCompletionObject(obj : AnyObject, success : AnyObject -> Void, failure : Void -> Void)
What does the ->
in AnyObject -> Void
mean?
Upvotes: 8
Views: 13907
Reputation: 80
success : AnyObject -> Void
This means that success parameter is a function that receives an object (AnyObject) and returns nothing (Void).
Upvotes: 4
Reputation: 3738
Syntax for closure expression separates Argument and Return type with a return arrow ->.
Upvotes: 0
Reputation: 54971
It’s a function type. AnyObject -> Void
is the type of a function accepting AnyObject
and returning Void
.
Upvotes: 11