I have tried to set a property value as in the following snippet.This SO question is not answering the question.
var person = Person("john", 24) //sample_text.text = person.getName() + person.getAge() var kon = person.someProperty person.someProperty = "crap" //this doesn't allow me to set value kon = "manulilated" //this allows me to set the value sample_text.text = kon class Person(val n: String, val a: Int){ var pname: String = n var page: Int = a var someProperty: String = "defaultValue" get() = field.capitalize() private set(value){field = value} fun Init(nm: String, ag: Int){ pname = nm page = ag } fun getAge(): Int{ return page } fun getName(): String{ return pname } } Why was I able to set the value of the Person class on the second line but not the first line?
getAge()andgetName()functions - kotlin automatically creates getters for all variables (apart from those annotated with@JvmField)