4

Just found out that something like this would actually work in Java:

int a = 2;
switch(a) {
case 1:
int b = 1;
break;
case 2:
b = 2;
}

I know about the variable scoping part, but that doesn't means if the language allows this kind of shitty code you should use it.. Fuck took me 15 mins to resolve the merge conflicts. As during merge the 1st case was partially removed. And the code was filled with these kinds of logic. This could have been done in a minute without the shitty code..

Comments
  • 0
    I had a nice comment almost done when I went back to reread this and saw the int in the first switch case. Dafuuuuuuuuq

    I mean, read or write to variables from upper scope but for fuck sake, define them there too.
  • 0
    @Froot yes that's what I thought.. Even if they are in the same scope how the fuck it is getting initialized even if it is never getting executed... And who the fuck comes with the idea of writing such spaghetti code..
  • 0
    Okay so basically the code you write gets read twice by the compiler, similarly to c++. Usually (not always, there are some special cases) every decalartion gets moved to the top of your scope, so gc can pretty much work symmetrically and clean up at the end.
  • 0
    Text 'woahm8' to 90-200-fuckmeup to subscribe to Bind's useless java fact of the day
Add Comment