Hacker News new | ask | show | jobs
by Detrytus 977 days 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.

1 comments

I mean yeah, in a language without default arguments, it certainly is typical to use the only other way (overloading) to easily emulate that behaviour.