I have a question, when you define a inner private...
# announcements
c
I have a question, when you define a inner private object like
Copy code
class A{
    private object O{
        const val someConstant = 1
    }
}
The object has some kind of lifecycle attached to the A class or is it created at the beggining no matter if A will be created or not?
g
There is no lifecyle, O is a singleton and has static field under the hood with instance of this companion object
c
ok thanks, I supposed that but wanted to make sure 🙂
k
But in practice if you put some side effect code in
init
of course it runs at some point and so there's a lifecycle.
I don't know whether Kotlin or even the JVM guarantees anything about it though.