i am a new Scala programmer and I have a question on Scala Array pattern matching:
def countErased(sorted: Array[Array[Int]], acc: Int): Int = {
sorted match{
case Array() | Array(_) => acc
case Array(h,n,_*) =>
if(n(0) < h(1)){
countErased(Array(h,_*), acc+1)
}else{
countErased(Array(n,_*), acc)
}
}
}
Basically what i want to do is: when we have an Array of length longer than 2, if n(0)< h(1), call function recursively with a new Array of the head and whatever as the tail. otherwise call function with a new Array of the next and whatever as the tail. But this code gets me an error:
"error: missing parameter type for expanded function ((<x$1: error>) => x$1.$times) (in solution.scala)
countErased(Array(h,_*), acc+1)"
What is wrong?