yeah I don't need tail guards, but if (foo.isValid()) { return; } is a lot :)
-
-
Replying to @wycats @BrendanEich
with paren-free and getters and more targeted lints, that could have been: if foo.isValid return; Which seems fine for guards
1 reply 0 retweets 0 likes -
Replying to @wycats
the case of the "then" part being just 'return;' is indeed special: easy to read even when skimming.
1 reply 0 retweets 0 likes -
Replying to @BrendanEich
the two special cases imo are `return` and simple throws (I abstract complex throws when used in guards to keep 'em shirt)
1 reply 0 retweets 1 like -
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 -
Frankly, I find that no-newline + mandatory curlies to create way more visual ambiguity.
1 reply 0 retweets 0 likes
function f(b) { if (b.isValid) { return; } more(things); } ^^ visually less clear to me
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.