14.06.2015 Views

Scala Tutorial

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

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

SYNTAX: ................................................................................................. 34<br />

EXAMPLE: .............................................................................................. 34<br />

The if...else if...else Statement: ............................................................... 35<br />

SYNTAX: ................................................................................................. 35<br />

EXAMPLE:............................................................................................... 35<br />

Nested if...else Statement: ...................................................................... 36<br />

SYNTAX: ................................................................................................. 36<br />

EXAMPLE:............................................................................................... 36<br />

<strong>Scala</strong> Loop Types .................................................................. 37<br />

while loop ................................................................................................ 38<br />

Syntax: .................................................................................................... 38<br />

Flow Diagram: ......................................................................................... 38<br />

Example: ................................................................................................. 39<br />

do…while loop ......................................................................................... 39<br />

Syntax: .................................................................................................... 39<br />

Flow Diagram: ......................................................................................... 40<br />

Example: ................................................................................................. 40<br />

for loop .................................................................................................... 41<br />

The for Loop with Ranges ....................................................................... 41<br />

Example: ................................................................................................. 41<br />

The for Loop with Collections .................................................................. 42<br />

Example: ................................................................................................. 43<br />

The for Loop with Filters .......................................................................... 43<br />

Example: ................................................................................................. 43<br />

The for Loop with yield: ........................................................................... 44<br />

Example: ................................................................................................. 44<br />

Loop Control Statements: ........................................................................ 45<br />

break statement ....................................................................................... 45<br />

Syntax: .................................................................................................... 45<br />

Flow Diagram: ......................................................................................... 46<br />

Example: ................................................................................................. 46<br />

Breaking Nested Loops: .......................................................................... 47<br />

Example: ................................................................................................. 47<br />

Infinite Loop: ............................................................................................ 48<br />

<strong>Scala</strong> Functions ..................................................................... 49<br />

Function Declarations: ............................................................................. 49<br />

Function Definitions: ................................................................................ 49<br />

Calling Functions: .................................................................................... 50<br />

<strong>Scala</strong> Closures ....................................................................... 57<br />

TUTORIALS POINT<br />

Simply Easy Learning

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

Saved successfully!

Ooh no, something went wrong!