3 ms·
I frequently reach for IIFE when I use switch/case. It's a very convenient (if maybe a bit weird looking) way of turning a statement into an expression. In othe
by jelder 1y ago
I frequently reach for IIFE when I use switch/case. It's a very convenient (if maybe a bit weird looking) way of turning a statement into an expression. In other words, `return 1` instead of `foo = 1; break` for a trivial example.
- hn_go_brrrrr 1y agoYes, this is works really well even outside of JS.
- ackfoobar 1y agoIn languages where more control flow constructs are expressions (if, match, try-catch) I don't need this, except if you count `run` in Kotlin. What language are you thinking of?
- hn_go_brrrrr 1y agoC++