09.10.2014 Views

Download Scala Tutorial (PDF Version) - Tutorials Point

Download Scala Tutorial (PDF Version) - Tutorials Point

Download Scala Tutorial (PDF Version) - Tutorials Point

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Breaking Nested Loops:<br />

Existing break has an issue while using for nested loops. So in case you have to use break for nested loops, then<br />

following is a way to proceed:<br />

Example:<br />

import scala.util.control._<br />

object Test {<br />

def main(args: Array[String]) {<br />

var a = 0;<br />

var b = 0;<br />

val numList1 = List(1,2,3,4,5);<br />

val numList2 = List(11,12,13);<br />

val outer = new Breaks;<br />

val inner = new Breaks;<br />

}<br />

}<br />

outer.breakable {<br />

for( a scala Test<br />

Value of a: 1<br />

Value of b: 11<br />

Value of b: 12<br />

Value of a: 2<br />

Value of b: 11<br />

Value of b: 12<br />

Value of a: 3<br />

Value of b: 11<br />

Value of b: 12<br />

Value of a: 4<br />

Value of b: 11<br />

Value of b: 12<br />

Value of a: 5<br />

Value of b: 11<br />

Value of b: 12<br />

C:/><br />

TUTORIALS POINT<br />

Simply Easy Learning

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!