How to implement variable without initializer ?
I found in Kotlin documentation:
val c: Int // Type required when no initializer is provided
c = 3 // deferred assignment
but this does not work. IDE requires to make a initializer.
I just want to assign value to "C" in other class
val can be used in two ways (counting 2 and 3 together):
For local variables, in which case assigning in other class makes no sense at all. The documentation you quote refers to this case.
For concrete properties, in which case they can be initialized separately from the declaration, but only in an init block of the class they are declared in.
For abstract properties. But in this case you can't assign them from other class, but only implement these properties.
For val you need to do the declaration and the assignment together.
For your case, this variable needs to be modified after the declaration section, therefore var c: Int will be better.
lateinit var?val.val c:Int by lazy { ... }