Optional

enum Optional<Wrapped>

A type that can represent either a Wrapped value or nil, the absence of a value.

Inheritance CustomDebugStringConvertible, NilLiteralConvertible, _Reflectable View Protocol Hierarchy →
Import import Swift

Cases

Initializers

init()

Construct a nil instance.

Declaration

init()
init(_:)

Construct a non-nil instance that stores some.

Declaration

init(_ some: Wrapped)
init(nilLiteral:)

Create an instance initialized with nil.

Declaration

init(nilLiteral: ())

Instance Variables

var debugDescription: String

A textual representation of self, suitable for debugging.

Declaration

var debugDescription: String { get }

Instance Methods

func flatMap(_:)

Returns nil if self is nil, f(self!) otherwise.

Declaration

func flatMap<U>(@noescape f: (Wrapped) throws -> U?) rethrows -> U?
func map(_:)

If self == nil, returns nil. Otherwise, returns f(self!).

Declaration

func map<U>(@noescape f: (Wrapped) throws -> U) rethrows -> U?