Hi, I'm a bit confused that nested objects dont work the same if the parent is a companion object. This works:
Copy code
object Foo {
object Bar {
val value = ""
}
}
val t = Foo.Bar.value
But if I put an object in a companion object then it doesn't work as smoothly:
Copy code
class Foo {
companion object {
object Bar {
val value = ""
}
val fooValue = ""
}
}
val t1 = Foo.fooValue
val t2 = Foo.Companion.Bar.value
val t3 = Foo.Bar.value // This doesn't work, unlike t1 and t2
e
ephemient
04/23/2024, 7:49 PM
Copy code
class Foo {
companion object {
object Bar
}
object Bar
}