Why does pattern matching in Scala not work with variables?
What you’re looking for is a stable identifier. In Scala, these must either start with an uppercase letter, or be surrounded by backticks. Both of these would be solutions to your problem: def mMatch(s: String) = { val target: String = “a” s match { case `target` => println(“It was” + target) case _ => … Read more