The following
def mMatch(s: String) = { var target: String = "a" s match { case `target` => println("It was " + target) case _ => println("It was something else") } } does not compile:
error: stable identifier required, but target found. case
target=> println("It was " + target)
Why does Scala require a val not a var. I guess "Because" would be an acceptable answer but I have the feeling there is a deeper reason I am missing.