- cross-posted to:
- lemmyshitpost@lemmy.world
- cross-posted to:
- lemmyshitpost@lemmy.world
cross-posted from: https://lemmy.blahaj.zone/post/31679150
proportional reaction
cross-posted from: https://lemmy.blahaj.zone/post/31679150
proportional reaction
I’ve been called slurs before for using immediately invoked anonymous function expressions with switch cases in JS
const [val1, val2] = (() => { switch(whatever) { case "foo": return [1, 2]; case "bar": return [3, 4]; default: return [0, 0]; } }))();
const [val1, val2] = ({ "foo": [1, 2], "bar": [3, 4], })[whatever] || [0, 0];
🤫
Yeah, the problem isn’t “conditional expressions”, it’s “terse syntax”, and operator rules that you need to just memorize because they’re special and different. Also being limited such that you need to nest the extremely deeply if you, for whatever, you need to have a complex inline condition.
I like the case expression , although I mostly know it from erlang.