error: cannot convert value of type '_ -> ()' to expected argument type 'inout User -> Void'
A possible workaround until now is adding a return statement.
let user = User() {
$0.name = "abc"
return
}
Solution
The cause of the error is: an inout parameter. It seemed like a Swift bug. In order to get rid of return statement, I've made a new extension on AnyObject that doesn't use inout parameter.
Limitation
This workaround is only available for reference types.
Problem
When using a closure with single line:
Then Swift compiler says:
A possible workaround until now is adding a
return
statement.Solution
The cause of the error is: an
inout
parameter. It seemed like a Swift bug. In order to get rid ofreturn
statement, I've made a new extension onAnyObject
that doesn't useinout
parameter.Limitation
This workaround is only available for reference types.