Maps the optional value with a default value fn().
fn()
The function to provide a default value.
The mapped value or init.
init
const strLenOrCalc = mapOrElse(() => 6 ** 4)((str: string) => str.length);expect(strLenOrCalc(some("Hello, World!"))).toStrictEqual(13);expect(strLenOrCalc(none())).toStrictEqual(1296); Copy
const strLenOrCalc = mapOrElse(() => 6 ** 4)((str: string) => str.length);expect(strLenOrCalc(some("Hello, World!"))).toStrictEqual(13);expect(strLenOrCalc(none())).toStrictEqual(1296);
Maps the optional value with a default value
fn().