After reading this answer I\'ve tried to play with this nice feature by myself and found out that it is ok when I\'m do
scala> val Array(a,b,n) = \"XXX,YY
Scala treats it as a constant against which to match the pattern. Observe:
scala> val N = 20
N: Int = 20
scala> val Array(a, b, N) = Array(11, 23, 20)
a: Int = 11
b: Int = 23
scala> val Array(a, b, N) = Array(11, 23, 21)
scala.MatchError: [I@195d471 (of class [I)
at .(:75)
at .()
at .(:11)
at .()
at $print()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:704)
at scala.tools.nsc.interpreter.IMain$Request$$anonfun$14.apply(IMain.scala:920)
at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43)
at scala.tools.nsc.io.package$$anon$2.run(package.scala:25)
at java.lang.Thread.run(Thread.java:662)
The variables in which you want to extract the values must begin with a lower-case letter.