Possible Duplicate:
Use of def, val, and var in scala
I'm learning now Scala and I can't modify variable in class.
class Person(name: String, var variable: Int) {
def change() {
variable = 42
}
}
def person = new Person("name", 0)
println(person.variable)
person.change()
println(person.variable)
And the output is:
0
0
Why output contains 2 times 0?
How I can modify variable in this Code?
I have Scala version 2.9.1.