The absolute worst thing I’ve ever seen was some shit like this:
public void IDontRememberTheName(int index)
string i = index.ToString();
There was absolutely no fucking reason whatsoever to convert it into a string, and IMO string switch statements shouldn’t be a thing anyway. I wanted to smack whoever wrote that shit.
I teach a Java class, and students often gravitate toward strings because of their functionality. Why try to get the third digit from a number using math (i.e. (5092 / 10) % 10) when you can convert it to a string and call the index method on it (i.e. Integer.toString(5092).charAt(3))?
(5092 / 10) % 10
Not making an excuse for this code! It's bad, but I can see why people do it. haha In this case, it really makes no sense.
Yeah, if they were actually doing something with the string, I wouldn’t have a problem. But converting it to use in a switch statement is absolutely horrible.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.