Option
Option[
SomeType
]
is an enum used to represent an optional value. Its type syntax takes one type parameter. An option has two variants:
Some
None
Example:
option_some: Option[Int] = Option[Int]::Some{42};
option_none: Option[Int] = Option[Int]::None; ...
Associated Functions
from_data
Option[SomeType]::from_data(data: Data) -> Option[SomeType]
Getters
Option[SomeType]::Some
some
Returns content of Option[
SomeType
]::Some
.
option_some.some -> SomeType
Note: this getter doesn't exist on
Option[
SomeType
]::None
.
Operators
==
Option[SomeType] == Option[SomeType] -> Bool
!=
Option[SomeType] != Option[SomeType] -> Bool
Methods
map
Maps None
to None
and Some
to Some
.
option.map(fn: (some: OldSomeType) -> NewSomeType) -> Option[NewSomeType]
serialize
option.serialize() -> ByteArray
unwrap
Returns the value wrapped by Some
. Throws an error if None
.
option.unwrap() -> SomeType