class Person(var name: String, val weight: Int) { var age: Int = 0; } val person = new Person("Anna", 100); println(person.name); println(person.age); println(person.weight); person.name = "Horst"; person.age = 30; // Scala Compiler ignoriert fachliche Fehler // person.weight = 50; geht nicht println(person.name); println(person.age); println(person.weight);
Sunday, September 23, 2012
Vals, Vars, Attributes and Contructors
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment