Skip to content

getSecondOrElse

getSecondOrElse<B, D>(defaultValue): <A>(data) => B | D

Defined in: Core/These.ts:262

Returns the second value, or a default if the These has no second value. The default can be a different type, widening the result to B | D.

B

D

() => D

<A>(data): B | D

A

These<A, B>

B | D

pipe(These.second("warn"), These.getSecondOrElse(() => "none")); // "warn"
pipe(These.both(5, "warn"), These.getSecondOrElse(() => "none")); // "warn"
pipe(These.first(5), These.getSecondOrElse(() => "none"));       // "none"
pipe(These.first(5), These.getSecondOrElse(() => null));         // null — typed as string | null