Function: fromResult()
fromResult<
T,E>(result):Option<T>
Defined in: option/constructors/index.ts:76
Converts a Result to an Option, discarding the error.
If the Result is Ok, returns Some with the value. If the Result is Err, returns None.
Type Parameters
T
T
E
E
Parameters
result
Result<T, E>
The Result to convert
Returns
Option<T>
Option containing the Ok value or None
Example
// When you don't care about the specific error
const maybeNumber = fromResult(parseNumber(str))
// Ok(42) => Some(42)
// Err('Invalid') => None