3 ms·
In Java, you'd just add a 'final' keyword to the base method and you'd get a compile time error if someone accidentally tried to override it. If you want the e
by cromwellian 12y ago
In Java, you'd just add a 'final' keyword to the base method and you'd get a compile time error if someone accidentally tried to override it.
If you want the equivalent of !@Override, a) you can do it with Java8 annotation types and a checker or b) you can just declare the method private.
I'm sure Swift's version also fails to address all of the edge cases people might want to catch. No type system can be complete and catch every use case.
- mercurial 12y agoYou can't always do b) since your object has to, well, do something. Personally, I'd like to make inheritance strictly opt-in (as in, classes marked final per default), if anything this may be enough to make some people think twice about the let's-use-inheritance-to-share-code antipattern.