Closures and functions are interchangeable. Any place you need to pass a closure, you can pass a function instead.
Thus you could write a function for both of your cases and pass that function name instead of a closure.
That said, your two examples show different parameters, which argues against your statement that "Both closures are exactly the same". If they take different parameters, how can they be the same?
Edit:
Consider the following function:
func foo(value: String, completion: (String)->Void) {
completion(value)
}
We could invoke foo using a closure, as you'd expect:
foo(value: "firstCall", completion: { value in
print("in completion handler, value = '\(value)'")
})
That would output
in completion handler, value = 'firstCall'
We could also define one or more functions who's signatures match the completion handler:
func completionFunction(value: String) {
print("In \(#function), value = '\(value)'")
}
func completionFunctionTwo(value: String) {
print("In \(#function), value = '\(value)'")
}
And then call those like this:
foo(value: "secondCall", completion: completionFunction)
foo(value: "thirdCall", completion: completionFunctionTwo)
Note how we're just passing a function name as the completion handler. That's equivalent to passing an in-line closure.
Those calls would output:
In completionFunction(value:), value = 'secondCall'
In completionFunctionTwo(value:), value = 'thirdCall'
Finally, you can create a variable that contains a closure, and pass that as your completion handler:
let aCompletionClosure: (String) -> Void = { value in
print("In completion closure, value = '\(value)'")
}
foo(value: "forthCall", completion: aCompletionClosure)
That outputs:
In completion closure, value = 'forthCall'