Scala - Variable

Card Puncher Data Processing

Evaluation time

def example = 2      // evaluated when called
val example = 2      // evaluated immediately
lazy val example = 2 // evaluated once when needed

Immutable

Creating immutable variable is very simple and doesn't require any extra effort. “val” keyword does the trick.

val numbers = List(1,2,3,4)







Share this page:
Follow us:
Task Runner