How to refer to the shaft in the statement of the case?

I have a slow morning. I thought that the link to the existing shaft in the statement of the case would be in order. But this seems to be interpreted as defining a local variable. A rudimentary googling did not help, and I do not have my staircase book with me.

What follows is what is the syntax that would allow me to match on case (b, c)?

scala> val (a,b,c) = (1,2,3) a: Int = 1 b: Int = 2 c: Int = 3 scala> (2,3) match { | case (a,b) => 100 | case (b,c) => 200 | case _ => 999 | } <console>:8: error: unreachable code case (b,c) => 200 
+4
source share
1 answer

You need to either smooth the val , or you must put the identifiers in the back ticks as follows:

  case (`b`, `c`) => 200 
+11
source

All Articles