Contents

as(_:)

Casts the raw value to the specified type.

Declaration

func `as`<T>(_ type: T.Type) throws -> T where T : LosslessStringConvertible

Discussion

If the raw value isn’t an instance of that type, this method throws an error.

let enumCase = MyEnumDefinition.makeCase("caseName")

try enumCase.as(String.self) == "caseName"