Lectures‎ > ‎

Week16

Scala

Overview
  • Pure object oriented
  • Functional


values and variables
var vs val
use val when possible


type inference

type specification
  val greeting: String = "hello"

semicolons optional

no primitive types, all types are objects

1.to(10)

1 to 10

functions and methods

singleton objects instead of static methods

control: expressions vs statements

most scala constructs return values (functional)

Use of unit type ()

if (x > 0) 1 else ()    

Block expressions

Comments