I am trying to achieve the following:
enum FunctionResult<T> {
case success(T)
case error(String)
}
func tester<T>(test: (…) -> FunctionResult<T>, onError: (String) -> T) -> T {
…
}
The problem is of course the (…) that simply does not work.
I would like to use this generic with a variety of different signatures, i.e.:
let result1 = tester(test: myfunc1(param: 26) -> FunctionResult<Bool>, onError:
{ … handle the error ... })
let result2 = tester(test: myfunc2(param: “A String") -> FunctionResult<Bool>,
onError: { … handle the error ... })
let result3 = tester(test: myfunc3(param: 26, param2: “String") ->
FunctionResult<Int>, onError: { … handle the error ... })
Is this at all possible?
Regards,
Rien
Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Balancingrock
Project: http://swiftfire.nl
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users