a.foreach(e => {
e match {
case a: Array[Int] if a.last == 5 =>
case _ =>
}
})
You can do something a little better for matching on the first elements:
a.foreach(e => {
e match {
case Array(1, _*) =>
case _ =>
}
})
, @_* . , .
scala> val Array(1, x @_*) = Array(1,2,3,4,5)
x: Seq[Int] = Vector(2, 3, 4, 5)
scala> val Array(1, b, 3, x @_*) = Array(1,2,3,4,5)
b: Int = 2
x: Seq[Int] = Vector(4, 5)