Switch in Scala (Pattern Matching)
Scala has a powerful pattern matching mechanism, that we can think of a kind of “switch” if we come from another programming language, but it’s much more powerful and I’d love to explore some of its options here. A simple switch in Scala would look like this: a match { case 1 => "One" case 2 => "Two" case _ => "Whatever" } In this case we have cases with 1 and 2, and if something else is matched then we return “Whatever”....