How can you enforce a setter method to be called on creating a object that can produce compile time warning or exception?
Suppose I've a class A which looked like this before:
class A(str:String){
// body
}
Now, I want to remove the parameter from the constructor instead I'll be using a setter for that value. Like below:
class A(){
lateinit var str:String
fun setStr(paramsString:String){
str = paramsString
}
}
As I am using a setter for assigning the value, it wont give me a compile time exception while creating the object of that class.
So, I tried something like below:
class A(){
lateinit var...