Result
public enum Result<A, B>
A result captures both successful and failed return values of a method.
-
A value representing a successful result.
Declaration
Swift
case success(A)
-
A value representing a failed result.
Declaration
Swift
case failure(B)
-
Create a successful result with the provided value.
Declaration
Swift
public init(success a: A)
Parameters
a
successful value represented by this result.
-
Create a failed result with the provided value.
Declaration
Swift
public init(failure b: B)
Parameters
b
failure value represented by this result.
-
Determine whether two results containing equatable values are equal.
Declaration
Swift
public static func==(lhs: Result, rhs: Result) -> Bool
Parameters
lhs
left-hand result to compare.
rhs
right-hand result to compare.
Return Value
true
if lhs are both successes or failures containing equal values.
-
Infix version of
See morebind
returning a value rather than a function.Declaration
Return Value
the result of
f
ifresult
was successful,result
otherwise.