Reputation: 2997
Given a function signature:
func myFunc(someClosure: (argA: TypeA!, argB: TypeB!) -> Void)
sometimes I don't need the passed parameters to the closure so the call is:
myFunc { (_,_) in
//bla bla
}
is there a way to skip this redundant (_,_) in
part?
Upvotes: 8
Views: 5491
Reputation: 6532
Personally I don't like turning parameters into ( _ )
, so I use ( _ paramName )
(Swift 3, Xcode 8.3 beta)
Upvotes: 2
Reputation: 12552
There is no way to skip it entirely, but if you won't use either argument, you can use
myFunc { _ in
// do stuff
}
Similarly, if you only need one of the arguments, you can use
myFunc { _, something in
// do stuff
}
Upvotes: 9