Rest
...args: AParameters passed to wrapped function.
opt
-wrapped result from the function
const add = (a: number, b: number) => a + b;
opt(add).apply(2, 3) // Some(5)
none.apply(0) // None
It can also be used with curried functions.
const sub = (a: number) => (b: number) => a - b;
opt(sub).apply(10).apply(3) // Some(7)
Opt.apply is only available for functions, otherwise an exception will be thrown when called on Some.
Opt.onFunc for imperative version
Apply (call) a function inside Some. Does nothing for None.