The following is a skeleton of break
in scala using util.control.Breaks._
:
import util.control.Breaks._
breakable {
for (oct <- 1 to 4) {
if (...) {
} else {
break
}
}
}
This structure requires remembering several non intuitive names. I do not use break
statements every other or third day - but part of that is the difficulty in remembering how to do them. In a number of other popular languages it is dead simple: break
out of a loop and you're good.
Is there any mechanism closer to that simple keyword/structure in scala
?