Creates an Option<T> representing the presence of a value. This function is typically used to construct an Option that contains a value, indicating that the operation yielding the value was successful.
Option<T>
Option
The type of the value to be wrapped in a Some.
Some
The value to wrap as a Some option.
An Option<T> that contains the provided value, representing the Some case.
1.0.0
const maybeValue = Some(1); // Option<number> with a valueif (maybeValue.isSome()) { console.log(maybeValue.unwrap()); // Outputs: 1} Copy
const maybeValue = Some(1); // Option<number> with a valueif (maybeValue.isSome()) { console.log(maybeValue.unwrap()); // Outputs: 1}
Creates an
Option<T>representing the presence of a value. This function is typically used to construct anOptionthat contains a value, indicating that the operation yielding the value was successful.