Re:Erlang Doesn’t Fit The JVM
by 10ren on Friday April 03, 2009 @12:13PM
(#545082)
It's not about methods with different signatures being being different methods, but about when they are bound. If a class has these methods:
and we make the following invocation - which one gets called? The static, compile-time type of the invocation is Object and the dynamic, runtime class of the invocation is String. Which one will select the method?
In Java, the first method gets called (the one taking an Object argument). Because the compile time type of this invocation is Object, it is bound to the first method, regardless of the runtime class of a. Even if a is a String. It's the compile time type that selects the method, not the runtime class. To select the other method, we need to change the compile time type:
[ Parent
| on HN ]
There are no comments on this comment yet.