@wallhackio not an undergrad but purrsonally i just despise how if-elseif chains look
@aescling but switch statements add a bunch of indentation so for me it's picking your poison
@wallhackio @aescling Do they?
switch (some_enum) {
case VALUE1:
do_something();
break;
case VALUE2:
do_something_else();
break;
}
vs.
if (some-enum == VALUE1) {
do_something();
} else if (some_enum == VALUE2) {
do_something_else();
}
That's the same amount of indentation...
@vaporeon_ @aescling oh I have a skill issue it seems
@wallhackio @vaporeon_ @aescling you should instead do
switch (gorp) {
case 'norp': {
console.log('norp')
break
}
// etc
}
@vaporeon_ @Lady @wallhackio they’re optional in javascript :3
@vaporeon_ @Lady @aescling JavaScript will auto insert semicolons if you don't add them
There are camps on whether or not you should manually add them
I think ignoring them makes more sense but it was a style convention at my old job to use them and the Deno autoformatter inserts semicolons so I just write them now out of habit
@wallhackio @Lady @aescling Just when I thought you couldn't make me hate JavaScripts even more
Cursed language
@vaporeon_ @wallhackio @aescling wait until you learn about Python
@Lady @vaporeon_ @aescling I only do that if I start declaring variables in the switchies
@wallhackio @vaporeon_ @aescling reasonable but then if you add a variable declaration you have to reindent the whole block so
@wallhackio @vaporeon_ @aescling really one should just not use switch statements unless you are writing Swift which actually does them well
@wallhackio @vaporeon_ hey @aescling how do you feel about
switch (false) {
case !cond1:
// …
case !cond2:
// …
}
you hater of elif
@Lady @wallhackio @vaporeon_ ftr i didn't actually end up thinking switch (true) was better and wouldn’t do it again because it’s just about equally as terrible as that
@aescling @wallhackio @vaporeon_ coffeescript allows a bare switch without a condition statement which effectively compiles to switch (true)
@Lady @wallhackio @vaporeon_ …interesting
@aescling @wallhackio @vaporeon_ coffeescript is good and fun but you have to install node to use it so it’s impossible to say whether it is worthwhile or not
@Lady @wallhackio @aescling Why are you removing the semicolons?