the two special cases imo are `return` and simple throws (I abstract complex throws when used in guards to keep 'em shirt)
-
-
Replying to @wycats @BrendanEich
I like forcing return to be on next line because I see all exit points when scanning vertically
1 reply 1 retweet 12 likes -
Especially useful when there is no highlighting, like in diffs
2 replies 0 retweets 2 likes -
Spotting returns is valuable to avoid accidentally putting teardown logic after early conditional return
2 replies 0 retweets 3 likes -
Replying to @dan_abramov @wycats
Well put. Being able to "see" the control flow graph is valuable; as is early-return (and no else-after-return gaffe!).
2 replies 0 retweets 2 likes -
Replying to @BrendanEich @dan_abramov
the kinds of guards I'm talking about are very visible: function f(b) { if (!b.isValid) return; // rest }
3 replies 0 retweets 2 likes -
Replying to @wycats @BrendanEich
When condition is long I could miss return at the end. But it depends for sure.
1 reply 0 retweets 1 like -
Replying to @dan_abramov @BrendanEich
if the condition is long, I don't consider it a "guard" and don't use this style.
2 replies 0 retweets 3 likes -
Yehuda Katz 🥨 Retweeted Yehuda Katz 🥨
the "at-scale" version of the pattern I use is this:https://twitter.com/wycats/status/782304826357014529 …
Yehuda Katz 🥨 added,
1 reply 0 retweets 3 likes -
progress on a bikeshed on Twitter: a wild unicorn appears!
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.