4 ms·
Why would overloading repeat the code? It's typical to do it like that (in Java): public int doStuff(int a, int b) { //some code } public int doStuff(int a) {
by Detrytus 3y ago
Why would overloading repeat the code? It's typical to do it like that (in Java):
public int doStuff(int a, int b) { //some code }
public int doStuff(int a) { return doStuff(a, 7);} // so b=7 by default.
No need to repeat actual business logic code.
Of course that gets complicated if there are many parameters with default values.
- mattstir 3y agoI mean yeah, in a language without default arguments, it certainly is typical to use the only other way (overloading) to easily emulate that behaviour.