![]() ![]() For example you create a library and you want a class from this library to be used but not extended. So: Use sealed to better control extending something. Also you can directly instantiate an internal class as long as you are doing it in the same module. So you can't even use or instantiate it in another module. Internal class can be used and extended in the same module just like a sealed class, but you can do neither in another module. So sealed class is basically an abstract class which can only be implemented in the same module. This means you can't do this nowhere: val x = M圜lass() You can't instantiate a sealed class directly neither in the same or another module. But you can still use both M圜lass and MyExtensionClass in another module.įor example you can do this in another module: val x: M圜lass = MyExtensionClass() Sealed class M圜lass then you can do this in the same module:īut you can't do the same thing in another module. Sealed class will be visible in all modules, but extendable only in the same module.
0 Comments
Leave a Reply. |