3 ms·
That is not what is meant by "idioms and stylistic aspects". Take, e.g. `o.map(v => ...).getOrElse(v2)` vs `o match case Some(v) => ... case None => v2`. The fo
by aassddffasdf 8y ago
That is not what is meant by "idioms and stylistic aspects". Take, e.g. `o.map(v => ...).getOrElse(v2)` vs `o match case Some(v) => ... case None => v2`. The former is idiomatic and preferred over the latter (but of course some jackass somewhere will disagree and argue incessantly about it).
- kornish 8y agoExactly right. I'm not referring to which line the braces go on, but rather how domains get modeled, how errors are handled, how functional or imperative the code is, etc.
- paulddraper 8y agoSide point, but AFIAK `fold()()` is most idiomatic in Scala.
- Nullabillity 8y agoAnd 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 8y agoYeah, I agree. ¯\_(ツ)_/¯