I am new to promises in Swift and using PromiseKit to try and create a very simple response in a playground and attempt to use it. I have the following code:
import UIKit
import PromiseKit
func foo(_ error: Bool) -> Promise<String> {
return Promise { fulfill, reject in
if (!error) {
fulfill("foo")
} else {
reject(Error(domain:"", code:1, userInfo:nil))
}
}
}
foo(true).then { response -> String in {
print(response)
}
}
However I get the following error:
error: MyPlayground.playground:11:40: error: cannot convert value of type '() -> ()' to closure result type 'String'
foo(true).then { response -> String in {