2 ms·
I mean, stuff like this isn't really defensible: switch (index) { case 0: return sound0; case 1: return sound1; case 2: ret
by torginus 4y ago
I mean, stuff like this isn't really defensible:
switch (index)
{
case 0: return sound0;
case 1: return sound1;
case 2: return sound2;
case 3: return sound3;
case 4: return sound4;
}
- 32gbsd 4y agoLook perfectly readable and easy to understand.
- chii 4y agoonly because there's no `default` case. You could argue that having `sound` as an array, and index into that array is better, but once again, what does "better" mean here? this code works as is, you will not get an array index out of bounds error. If this is quick and easy to write, what else could you ask for?