CLOVIS
01/03/2025, 9:41 AM// #1
class Outer {
fun inner(): Any = Inner()
private inner class Inner
}
// #2
class Outer {
fun inner(): Any = Inner(this)
private class Inner(val outer: Outer)
}
From my understanding, these are both absolutely identical, but maybe some platforms have magic ways of handling the first one better?Huib Donkers
01/03/2025, 10:52 AMclass Outer {
fun inner(): Any = Inner()
private inner class Inner {
class A // compile error: must be inner class
}
}
class Outer {
fun inner(): Any = Inner(this)
private class Inner(val outer: Outer) {
class A // allowed
}
}CLOVIS
01/03/2025, 11:09 AMephemient
01/03/2025, 12:14 PMobject,
class Outer {
inner class Inner {
companion object
(or any other nested object type) is rejected, while
class Outer {
class Inner {
companion object
is OK. which sort of makes sense to me as Outer.Inner can't exist without an Outer, so an Outer.Inner.Companion which can exist without Outer is strangeephemient
01/03/2025, 12:25 PM