Thursday, March 29, 2012

Scala Basics - Simple Expression

Here is simple expression in Scala.

Scala> 7 + 7 res0: Int = 14 Scala> 4.5+9.3 res0: Double = 13.8
Scala interpreter automatically created value name(res0) for result of the expression. Last expression, res0 has Double type and stores 13.8 value.

You can define you're own name for a expression through "val".

scala> val result = 4*5 result: Int = 20
You cann't change the binding to a val.Almost everything in Scala is an expression.

No comments:

Post a Comment