Optional

extension Optional: CustomStringConvertible
extension Optional: OptionalType
public extension Optional where Wrapped: Collection
public extension Optional where Wrapped == String
public extension Optional where Wrapped == Data
public extension Optional where Wrapped: Occupiable
public extension Optional where Wrapped: Collection & Occupiable
public extension Optional where Wrapped: InitializeableOccupiable
  • Declaration

    Swift

    public var description: String { get }
  • Cast Optional<Wrapped> to Wrapped?

    Declaration

    Swift

    public var value: Wrapped? { get }

Available where Wrapped: Collection

  • Check if object is nil or empty

    Declaration

    Swift

    var isNilOrEmpty: Bool { get }

Available where Wrapped == String

  • Check if object is nil or empty

    Declaration

    Swift

    var isNilOrEmpty: Bool { get }

Available where Wrapped == Data

  • Check if object is nil or empty

    Declaration

    Swift

    var isNilOrEmpty: Bool { get }

Available where Wrapped: Occupiable

  • true if current occupiable optional is either nil or empty, false otherwise.

    Declaration

    Swift

    var isNilOrEmpty: Bool { get }
  • true if current occupiable optional represents some non-empty value.

    Declaration

    Swift

    var isNotEmpty: Bool { get }
  • Unwraps optional and replaces empty value by nil.

    Declaration

    Swift

    var nonEmpty: Wrapped? { get }

Available where Wrapped: Collection & Occupiable

  • Property equal to isNotEmpty property. Added just because in the case of Collection types, ‘hasElements’ is more descriptive name than ‘isNotEmpty’.

    Declaration

    Swift

    var hasElements: Bool { get }

Available where Wrapped: InitializeableOccupiable

  • Unwraps optional and replaces nil value by empty value.

    Declaration

    Swift

    var nonNil: Wrapped { get }