2 ms·
It's really nice syntactic sugar. Complicated conditional logic cluttered with redundant types turns into a series of simple patterns. "Just" makes it easier to
by dcminter 4y ago
It's really nice syntactic sugar. Complicated conditional logic cluttered with redundant types turns into a series of simple patterns. "Just" makes it easier to not make stupid bugs (I'm all for it).
- therealdrag0 4y agoAgreed. Example from Scala // Given an Option val maybeThing: Option[String] = getThing() // Classic if (maybeThing.isDefined) { useThing(maybeThing.get) } else { NotFoundResponseEtc() } // Pattern matching (not too IDE auto generated exhaustive match cases!) maybeThing match { case Some(thing) => useThing(thing) case None => NotFoundResponseEtc() } This scales well when matching a higher cardinality of things like a variety of Exceptions or enums or other tuple responses like Either etc.