MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/cobp4u/absolute_genius/ewhjomp/?context=3
r/badcode • u/[deleted] • Aug 10 '19
59 comments sorted by
View all comments
0
[deleted]
70 u/pierovera Aug 10 '19 I get this is shitty code, but this wouldn't even compile. 19 u/fond42518 Aug 10 '19 Can't even try compiling bc I'm on mobile rn. Is it because the redeclaration of k in the second method? 1 u/[deleted] Aug 10 '19 edited Aug 10 '19 I’m not sure but I thought in most languages you can only overload the constructor like that?Edit: Sounds like I was right not to be sure 3 u/fond42518 Aug 10 '19 I'm assuming this code is Java, in which a class's methods can be overloaded as long as their input parameters are different.Edit: nvm, just saw the C# flair 2 u/dbgprint Aug 10 '19 What languages can’t do this? C++ can do it too, as long as the function signature is different
70
I get this is shitty code, but this wouldn't even compile.
19 u/fond42518 Aug 10 '19 Can't even try compiling bc I'm on mobile rn. Is it because the redeclaration of k in the second method? 1 u/[deleted] Aug 10 '19 edited Aug 10 '19 I’m not sure but I thought in most languages you can only overload the constructor like that?Edit: Sounds like I was right not to be sure 3 u/fond42518 Aug 10 '19 I'm assuming this code is Java, in which a class's methods can be overloaded as long as their input parameters are different.Edit: nvm, just saw the C# flair 2 u/dbgprint Aug 10 '19 What languages can’t do this? C++ can do it too, as long as the function signature is different
19
Can't even try compiling bc I'm on mobile rn. Is it because the redeclaration of k in the second method?
k
1 u/[deleted] Aug 10 '19 edited Aug 10 '19 I’m not sure but I thought in most languages you can only overload the constructor like that?Edit: Sounds like I was right not to be sure 3 u/fond42518 Aug 10 '19 I'm assuming this code is Java, in which a class's methods can be overloaded as long as their input parameters are different.Edit: nvm, just saw the C# flair 2 u/dbgprint Aug 10 '19 What languages can’t do this? C++ can do it too, as long as the function signature is different
1
I’m not sure but I thought in most languages you can only overload the constructor like that?
Edit: Sounds like I was right not to be sure
3 u/fond42518 Aug 10 '19 I'm assuming this code is Java, in which a class's methods can be overloaded as long as their input parameters are different.Edit: nvm, just saw the C# flair 2 u/dbgprint Aug 10 '19 What languages can’t do this? C++ can do it too, as long as the function signature is different
3
I'm assuming this code is Java, in which a class's methods can be overloaded as long as their input parameters are different.
Edit: nvm, just saw the C# flair
2
What languages can’t do this? C++ can do it too, as long as the function signature is different
0
u/[deleted] Aug 10 '19
[deleted]