You can't do a = b = c
because a
has already been defined as a Int var
, and with the a = b = c
statement you are giving a
a Unit
, 'b = c'.
When you assign a value to a variable in Scala you don't get as a result the value assigned.
In other languages b = c
would be evaluated to 23, the value of c. In Scala b = c
is just a Unit
, writing a = b = c
is exactly like writing a = (b = c)
, hence the error.