class NodeL(a :Int){
var value = a
}
def change(x :NodeL) = {
if(x == null) x = new Node
}
when I use code above ,compiler give me an error "reassignment to val" in the statement "if(x == null) x = new Node" why?
class NodeL(a :Int){
var value = a
}
def change(x :NodeL) = {
if(x == null) x = new Node
}
when I use code above ,compiler give me an error "reassignment to val" in the statement "if(x == null) x = new Node" why?
You can't, method parameters are immutable in scala (i.e., they are vals
)