我尝试在result
方法中返回常量test2
,但是编译器抛出错误。为什么?
public enum TestResult<Value> {
case success(Value)
case failure(Error)
}
struct TestModel {
}
class Test {
func test1() -> TestResult<Any> {
let obj = TestModel()
return TestResult.success(obj)
}
func test2() -> TestResult<Any> {
let obj = TestModel()
let result = TestResult.success(obj)
return result
}
}
答案 0 :(得分:-1)
您需要将URL
转换为TestModel
:
Any