Scala best practice: Use match expressions and pattern matching
By Alvin Alexander. Last updated: February 16 2018
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 20.4, “Scala best practice: Use match expressions and pattern matching.”
Back to topProblem
Match expressions (and pattern matching) are a major feature of the Scala programming language, and you want to see examples of the many ways to use them.
Back to topSolution
Match expressions (match/case statements) and pattern matching are a major feature of the Scala language. If you’re coming to Scala from Java, the most obvious uses are:
Back to top