Skip to content

getFirstOrElse

getFirstOrElse<A, C>(defaultValue): <B>(data) => A | C

Defined in: Core/These.ts:247

Returns the first value, or a default if the These has no first value. The default can be a different type, widening the result to A | C.

A

C

() => C

<B>(data): A | C

B

These<A, B>

A | C

pipe(These.first(5), These.getFirstOrElse(() => 0));            // 5
pipe(These.both(5, "warn"), These.getFirstOrElse(() => 0));     // 5
pipe(These.second("warn"), These.getFirstOrElse(() => 0));      // 0
pipe(These.second("warn"), These.getFirstOrElse(() => null));   // null — typed as number | null