harry.singh
03/08/2019, 6:29 AMclass Person (val name : String, age : Int = 3) {
var age : Int = 5
}
What is difference between age
as constructor parameter and as a field? When I try to access the age
field, it always prints the fields value. Why does Kotlin allows to define a variable with same name couple of times here? And if we don't define the constructor parameter as val
, then is it var
by default?