class Solution { val message: String //error : val must be initialized or abstract message = "love" //error : val cannot be reassigned}
I understand what's happening in here - val cannot be reassigned.
So when I need val but can not initialize it i used to use by lazy
class Solution { fun love(){ val message : String message = "love" //this works message = "hate" //this is error "val cannot be reassigned" }}
Here I can delcare val without initialization and later write codemessage = "love"
.what's happening here?