Returns this container if it has a value, otherwise returns the alternative container.
The alternative may carry a different type; the result widens to Extractable<T | T2>.
The alternative container
This container or the alternative
Extract the value or throw an error
Optionalerror: ErrorOptional custom error to throw. If not provided, uses type-appropriate default error
The contained value
Extractable type class for data structures that can extract their values with various fallback strategies.
Covariance: T is declared
<out T>. The fallback methodsorElseandorwiden the result via<T2>, matching Scala'sgetOrElse[B1 >: B](default: => B1): B1shape — when the caller passes a T-typed default the result is just T, and when they pass a wider T2 the result union widens accordingly.Implementers that previously overrode
or/orElsewith widened signatures (Option, Either, Try) can inherit from this base directly; their 0.58-eraOmit<Extractable<T>, "or" | "orElse">workarounds are no longer needed.