O'Reilly logo
  • Xing Ping Zhang thinks this is interesting:

The var and val keywords only specify whether the reference can be changed to refer to a different object (var) or not (val). They don’t specify whether or not the object they reference is mutable.

From

Cover of Programming Scala, 2nd Edition

Note

var 和 val只是明确了引用是否能被修改,而没有明确所引用的对象是否是不可修改的。 var = variable,表明其引用可以被修改; val = value,表明其引用不能被修改。