Rest
...args: AUnchanged Opt instance
Both lines do the same thing
opt(f).onSome(x => x())
opt(f).onFunc()
const g = (a: number, b: number): void => console.log(a, b);
opt(g).onFunc(1, 2) // calls `g` (prints 1 and 2), returns Some(g)
none.onFunc(79) // None
onFunc is only available for functions, otherwise an exception will be thrown when called on Some.
Opt.apply for functional version
Apply (call) a function inside Some. Does nothing for None.