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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

var a = 10;<br />

var b = 20;<br />

var c = 25;<br />

var d = 25;<br />

println("a + b = " + (a + b) );<br />

println("a - b = " + (a - b) );<br />

println("a * b = " + (a * b) );<br />

println("b / a = " + (b / a) );<br />

println("b % a = " + (b % a) );<br />

println("c % a = " + (c % a) );<br />

}<br />

}<br />

This would produce the following result:<br />

C:/>scalac Test.scala<br />

C:/>scala Test<br />

a + b = 30<br />

a - b = -10<br />

a * b = 200<br />

b / a = 2<br />

b % a = 0<br />

c % a = 5<br />

C:/><br />

Relational Operators:<br />

There are the following relational operators supported by <strong>Scala</strong> language<br />

Assume variable A holds 10 and variable B holds 20, then:<br />

Operator Description<br />

Example<br />

==<br />

Checks if the values of two operands are equal or not, if yes then<br />

condition becomes true.<br />

(A == B) is not true.<br />

!=<br />

Checks if the values of two operands are equal or not, if values are<br />

not equal then condition becomes true.<br />

(A != B) is true.<br />

><br />

Checks if the value of left operand is greater than the value of right<br />

operand, if yes then condition becomes true.<br />

(A > B) is not true.<br />

<<br />

Checks if the value of left operand is less than the value of right<br />

operand, if yes then condition becomes true.<br />

(A < B) is true.<br />

>=<br />

= B) is not true.<br />

(A

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

Saved successfully!

Ooh no, something went wrong!