4 ms·
The add1 method was declared non static on purpose, to illustrate static type checking.
by the_af 12y ago
The add1 method was declared non static on purpose, to illustrate static type checking.
- shawabawa3 12y agoNo it wasn't. Even if the type checker passed the compilation would fail because it's trying to call a non static method from a static method
- the_af 12y agoOh, you're right, it's unintended. I didn't see the author tried to trigger a type-check error with an argument "a" of the wrong type. However, failing compilation because you're calling a non-static method from a static context is also a kind of static checking, so the author's example still works, just in unintented ways.