Skip to content
mattpolzin edited this page Jun 11, 2021 · 5 revisions

Either

Can contain a value of either type A or type B.

public enum Either<A, B> 

If it contains a value of type A, then the value can be accessed with the .a property and similarly for type B and the .b property.

A type-erased value can be retrieved with the .value property.

Inheritance

CustomDebugStringConvertible, CustomStringConvertible, Decodable, Encodable, LocallyDereferenceable

Initializers

init(_:)

public init(_ a: A) 

init(_:)

public init(_ b: B) 

Enumeration Cases

a

case a(A)

b

case b(B)

Properties

description

public var description: String 

debugDescription

public var debugDescription: String 

a

Get the first of the possible values of the Either (if it is set).

public var a: A? 

This is sometimes known as the Left or error case of some Either types, but OpenAPIKit makes regular use of this type in situations where neither of the possible values could be considered an error. In fact, OpenAPIKit sticks to using the Swift Result type where such semantics are needed.

b

Get the second of the possible values of the Either (if it is set).

public var b: B? 

value

public var value: Any 
Types
Protocols
Global Functions
Extensions
Clone this wiki locally