WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Scala - IF ELSE Statements


This chapter takes you through the conditional construction statements in Scala programming.

if Statement

‘if’ statement consists of a Boolean expression. If block executes only when condition is true otherwise execution of if block is skipped.

Syntax

  1. if(condition){  
  2.     // Statements to be executed  
  3. }  
Scala If statement 1

If not, the first set of code after the end of the ‘if’ expression (after the closing curly brace) will be executed.

Scala Example: If Statement

var age:Int = 12;  
  • if(age > 18){  
  •     println ("Age is greate than 13 Teenage")  
  • }  

    Output

    Age is greate than 13 Teenage