Описание тега optional
An immutable type that may contain a value or reference. Each instance of this type either contains a non-null value or reference, or contains nothing (in which case we say that the reference is "absent"; it is never said to "contain null").
Found in programming languages such as Haskell (Maybe
), Scala and Rust (Option
), Apple's Swift (Optional<T>
or T?
), Java (Optional<T>
) or F# (option
).
C++ has a similar type (std::optional<T>
) but it is not immutable and cannot store references, so should use the tag stdoptional instead.