this works as expected
scala> 3 match { case x:Int => 2*x } res1: Int = 6
why does this fail?
scala> 3 match { case $x:Int => 2*$x } :1: error: '=>' expected but ':' found. 3 match { case $x:Int => 2*$x } ^ scala> 3 match { case `$x`:Int => 2*$x } :1: error: '=>' expected but ':' found. 3 match { case `$x`:Int => 2*$x } ^ scala> 3 match { case `$x` : Int => 2*$x } :1: error: '=>' expected but ':' found. 3 match { case `$x` : Int => 2*$x }
'$' is supposed to be a valid identifier character, as demonstrated here:
scala> var y = 1 y: Int = 1 scala> var $y = 2 $y: Int = 2
Thanks
$
. – Randall Schulz