therealbluepandabear
04/13/2021, 12:06 AMturansky
04/13/2021, 1:03 AMFoo
instances
class Foo {
init {
println(Foo.phello) // Works
println(Foo.hello) // ERROR
}
private companion object {
val phello = "world"
private val hello = "world"
}
}
turansky
04/13/2021, 1:03 AMnanodeath
04/13/2021, 2:49 AMYoussef Shoaib [MOD]
04/13/2021, 3:00 AMnanodeath
04/13/2021, 3:12 AMFoo.Companion.INSTANCE
or whatever, even if they're empty. on the other hand, if you're going to be adding public static state soon, it's easier to make the companion object public; otherwise you have to add private to all the now-public-but-should-be-private fields after making the companion object public