3 ms·
"The open annotation on a class is the opposite of Java's final: it allows others to inherit from this class. By default, all classes in Kotlin are final, which
by dmcg 15y ago
"The open annotation on a class is the opposite of Java's final: it allows others to inherit from this class. By default, all classes in Kotlin are final, which corresponds to Item 17 of Effective Java: Design and document for inheritance or else prohibit it."
This is an odd decision, puts me in mind of Yegge's rant -http://steve-yegge.blogspot.com/2010/07/wikileaks-to-leak-5000-open-source-java.html http://steve-yegge.blogspot.com/2010/07/wikileaks-to-leak-50...
- masklinn 15y agoDoes C# not use the same default of non-inheritable classes? Or is it just at the method level, where you have to mark methods as overridable?
- dmcg 15y agoYou have to mark methods as virtual - I believe classes are by default.
- ppog 15y agoClasses in C# are inheritable by default, as in Java, but can be marked sealed (final). Members (methods and properties) in C# are final by default, and must be explicitly marked virtual.
- frou_dh 15y agoFor what it's worth, Jon Skeet of StackOverflow fame and C# fanaticism, thinks C# classes should also be sealed by default. "I'd say it was just a mistake. I know many people (including myself) who believe that classes should indeed be sealed by default. There are at least a couple of people in the C# design team in that camp. The pendulum has swung somewhat away from inheritance since C# was first designed. (It has its place, of course, but I find myself using it relatively rarely.)"
- masklinn 15y agoAh, that's where I got confused, I remembered there was something in C# which made classes not-really-inheritable by default but had no way to test it.