Optional

extension Optional
  • Returns the wrapped value, assuming it exists, leaving this optional empty.

    Declaration

    Swift

    public mutating func release() -> Wrapped
  • If self is nil, wraps and returns newValue; returns the wrapped value otherwise.

    Declaration

    Swift

    public mutating func setIfNil(
      _ newValue: @autoclosure () throws -> Wrapped
    ) rethrows -> Wrapped
  • Evaluates the given closure when this Optional instance is not nil, passing the unwrapped value as a parameter; returns defaultValue otherwise.

    Declaration

    Swift

    public func map<U>(
      default defaultValue: @autoclosure () -> U,
      _ transform: (Wrapped) -> U
    ) -> U