Surely there must be a better way

3 years ago by 2e8a9d6bb6935a54 to c/programminghumor

If only string maps were known to human kind :)

WaveWood 17 points 3 years ago

Clearly the issue is that they are using switch cases instead of if statements /s

path: 0 704511, hotness: undefined, score: 17, children: 0
bwrsandman 10 points 3 years ago

Maps? Could get away with an array!

path: 0 705383, hotness: undefined, score: 10, children: 0
Kojak747 4 points 3 years ago

For shame, I recently did something like this, but only because a/ I have been programming for 3 weeks and b/ told chat gpt to edit my code. Either way, we both failed. Use arrays people!

path: 0 711924, hotness: undefined, score: 4, children: 0
Ignisnex 3 points 3 years ago

Case with numbers? I really want to change that to an enum or something lol.

path: 0 708330, hotness: undefined, score: 3, children: 0
nbdy 3 points 3 years ago

How about a dict[int, str], which holds your case and newscript?

path: 0 722158, hotness: undefined, score: 3, children: 0
MelodiousShark 2 points 3 years ago

Yes there is and, at least on reddit, you'd have people defending this code for no reason other than it works and the only bad code is code that doesn't work or something stupid like that.

path: 0 716558, hotness: undefined, score: 2, children: 0
shotgun_crab 1 point 3 years ago

I love how they even copied the comment

path: 0 725243, hotness: undefined, score: 1, children: 0