I'm writing this function in order to identify the first missing element from the array. I want to return the missing element but I'm getting a Unit
I can't identify what am I missing
def missingElement(a : Array[Int]) : Int = {
val result =for (i <- 1 to a.length) {
if(! a.contains(i)) {
i
}
}
result
}