标签: scala
class NodeL(a :Int){ var value = a } def change(x :NodeL) = { if(x == null) x = new Node }
当我使用上面的代码时,编译器在语句“if(x == null)x = new Node”中给我一个错误“重新分配给val”为什么?
答案 0 :(得分:5)
你不能,方法参数在scala中是不可变的(即它们是vals)
vals