2

I am currently studying kotlin's sealed classes

According to the documentation

A sealed class can have subclasses, but all of them must be declared in the same file as the sealed class itself

However, my testing seems to suggest that there is more detail than this.

I was able to find out that the previous quoted statement only applies to top-level (package-level) declarations.

For example, a sealed class inside an object can only be extended by nested members of that sealed class and can't be extended across the same file

The Questions :

  • Are there any other limitations that i am not aware of?

  • Is my conclusion/finding accurate?

Testing Source Code

0 Answers0