Using all three (
), I initialize, and then attempt to reassign. Onlyvar` succeeds (as it should), but the other two fail in different ways.
scala> val x = 6 x: Int = 6 scala> x = 7 <console>:11: error: reassignment to val x = 7 ^ scala> var x = 6 x: Int = 6 scala> x = 7 x: Int = 7 scala> def x = 6 x: Int scala> x = 7 <console>:11: error: value x_= is not a member of object $iw x = 7 ^
Deceptively similar at first, but I suppose you get used to it. Also, what the heck is
$iw ?? (I’m guessing it’s an internal Java representation of the