Optional

public extension Optional
extension Optional: OptionalType
extension Optional:
    ExpressibleByStringLiteral,
    ExpressibleByExtendedGraphemeClusterLiteral,
    ExpressibleByUnicodeScalarLiteral
    where Wrapped: ExpressibleByStringLiteral
extension Optional: ExpressibleByIntegerLiteral where Wrapped: ExpressibleByIntegerLiteral
extension Optional: ExpressibleByBooleanLiteral where Wrapped: ExpressibleByBooleanLiteral
extension Optional: ExpressibleByFloatLiteral where Wrapped: ExpressibleByFloatLiteral
extension Optional: ExpressibleByArrayLiteral where Wrapped: ExpressibleByArrayLiteral
extension Optional: ExpressibleByDictionaryLiteral where Wrapped: ExpressibleByDictionaryLiteral, Wrapped.Key: Hashable
  • Returns unwrapped value, or fails.

    Declaration

    Swift

    func orFail(_ message: String = "unwrapping nil") -> Wrapped

    Parameters

    message

    Failure message

    Return Value

    Unwrapped value

Optionality checks

  • Undocumented

    Declaration

    Swift

    public var isNotNil: Bool { get }

Available where Wrapped: ExpressibleByStringLiteral

Available where Wrapped: ExpressibleByIntegerLiteral

Available where Wrapped: ExpressibleByBooleanLiteral

Available where Wrapped: ExpressibleByFloatLiteral

Available where Wrapped: ExpressibleByArrayLiteral

Available where Wrapped: ExpressibleByDictionaryLiteral, Wrapped.Key: Hashable

  • Key

    Declaration

    Swift

    public typealias Key = Wrapped.Key
  • Declaration

    Swift

    public typealias Value = Wrapped.Value
  • Declaration

    Swift

    public init(dictionaryLiteral elements: (Key, Value)...)