Scala While Loop
In Scala, break out of a loop needs to be implemented with
1
import scala.util.control.Breaks._
2
breakable {
3
​
4
}
Copied!
block code
While loop statement example.
1
import scala.util.control.Breaks._
2
var tl=Seq(1,2,3,4,5)
3
var counter=0
4
breakable {
5
while (true)
6
{
7
if (counter>=tl.length)
8
break
9
counter+=1
10
}
11
}
12
​
Copied!
Last modified 1yr ago
Copy link