valueOr method

T valueOr(
  1. T defaultValue
)

Returns the converted value when successful, or defaultValue on failure.

Useful for providing fallback values without exception handling overhead.

Implementation

T valueOr(T defaultValue) => _error == null ? (_value as T) : defaultValue;