3 ms·
And yet, `match` is the only one that gets correct type inference. `.map(ifSome).getOrElse(ifNone)` infers the type from `ifSome`, and forces `ifNone` to confo
by Nullabillity 9y ago
And yet, `match` is the only one that gets correct type inference.
`.map(ifSome).getOrElse(ifNone)` infers the type from `ifSome`, and forces `ifNone` to conform.
`.fold(ifNone)(ifSome)` infers the type from `ifNone`, and forces `ifSome` to conform.
Meanwhile, `match { case Some(x) => ifSome(x); case None(x) => ifNone }` will correctly infer from both cases at once, and give you the greatest common ancestor.
- paulddraper 9y agoYeah, I agree. ¯\_(ツ)_/¯