Table of Contents
while Loop
while (condition)
{
// Code to be executed
}
do..while Loop
do {
// statements to be Executed
} while(condition);
for Loop
for( var x <- Range ){
statement(s);
}
break Statement
// import following package
import scala.util.control._
// create a Breaks object as follows
val loop = new Breaks;
// Keep the loop inside breakable as follows
loop.breakable {
// Loop will go here
for(...){
....
// Break will go here
loop.break;
}
}
Or
import scala.util.control.Breaks._
breakable
{
for(..)
{
code..
break
}
}