I have a method in Scala that checks if a game board is full or not. To speed this method up, I return inside the nested for loop to break out of both of them and stop execution. How would I achieve this in Scala in an idiomatic way?
def isFull: Boolean = {
for (x <- getGrid.indices) {
for (y <- getGrid(x).indices) {
if (getGrid(x)(y).getState.isInstanceOf[Undecided]) {
return false
}
}
}
true
}