when I run the following codes, the "error: reassignment to val" be thrown, anyone knows why?
def main(args: Array[String]) :Unit = {
var a = 10
def Fun(a:Int):Unit = {
while( a < 20 ){
println( "Value of a: " + a );
a = a + 1 // Error: reassignment to val
}
}
Fun(a)
}
If I want to implement the function of variable a plus one in the function Fun, how to modify it?