struct Optional<T>

Conforms to: IDefaultInitializable

Conditionally conforms to: IDifferentiable, IDifferentiablePtrType

Description

Optional<T> is a type with one extra value than T, this extra value is used to represent a “missing” or “invalid” T. This extra value is called none.

none can be compared against with the operators == or !=.

An Optional<T> value can also be implicitly or explicitly constructed from a value of type T

Optional<T> values can be deconstructed with if(let myT=myOptionalT)… where this branch will only be taken if myOptionalT contains a value of type T (to be put into scope as myT).

Generic Parameters

T

Properties

hasValue

Return true iff this Optional contains a value of type T

value

If this Optional contains a value of type T return that.

Methods

Conditional Conformances

Conformance to IDifferentiable

Optional<T> additionally conforms to IDifferentiable when the following conditions are met:

Conformance to IDifferentiablePtrType

Optional<T> additionally conforms to IDifferentiablePtrType when the following conditions are met: