What's the difference between val and var?
- A
valvariable can not have it's value changed, but avarvariable can.
What's the deal with implicit val?
- Marking a value as
implicitallows it to be used by functions that accept implicit parameters.
def fn(x: Int)(implicit y: Boolean) = if(y) x else - x
fn(1)(true) // returns 1
implicit val b = false
fn(1) // returns -1 using b as the argument for the implicit argument