Multiple assignment of non-tuples in scala

All you need to do is make your val side (left of the =) compatible with your initializer (right of the =):

scala> val Array(x, y, z) = "XXX,YYY,ZZZ".split(",")
x: java.lang.String = XXX
y: java.lang.String = YYY
z: java.lang.String = ZZZ

As you expected, a scala.MatchError will be thrown at runtime if the array size don’t match (isn’t 3, in the above example).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)