Variable definitions in Scala are actually pattern matching. That is, when you write
val x = y
println(x)
That's basically the same as writing
y match {
case x =>
println(x)
This can easily be seen in things like this:
val List(a, b, c) = someList
val RegexPattern(year, month, date) = "2013-10-23"
Another thing that's valid is constant pattern matching:
object X {
val One = 1
}
scala> val X.One = 1
scala> val X.One = 2
scala.MatchError: 2 (of class java.lang.Integer)
And anything with a parenthesis will call an extractor:
object Y {
val ymd = """(\d\d\d\d)-(\d\d)-(\d\d)""".r
}
scala> val Y.ymd(year, month, day) = "2013-10-23"
year: String = 2013
month: String = 10
day: String = 23
So, you see, there's nothing syntactically illegal with what you wrote, just the specifics.