Sometimes you may need to perform a match
against the current value of a val
. The most obvious attempt is not going to work, because the name of the val
gets re-bound within the match
statement, like this:
val s = 5 //> s : Int = 5
val t = 4 //> t : Int = 4
t match {
case s => println(s"matched $s")
case _ => println("outta here!")
} //> matched 4
What is the most direct way to match against the current value of s
?