Closed jeff-h closed 4 years ago
If it helps anyone else, I found that explicitly specifying the return type resolves the issue:
let myPromise = Promise<Void>.pending()
.then { _ -> String in
print("a")
return "a"
}
...in which case the myPromise
variable is of type Promise<String>
.
Would something like this be useful to put into the docs? Happy to create a PR.
In the docs for
then()
it states:This compiles as expected:
This doesn't compile, with the error
Unexpected non-void return value in void function
.I suspect the single-line examples leverage Swift 5.1's 'implicit returns' to infer the return type.
Hopefully I'm not exposing some embarrassing personal ignorance of Swift here but can anyone explain what I need to do to get the second example to compile?