IMO: Never else-for. (or else-while)
Else-if is a reasonable continuation of concept: "Well it wasn't that,
what if it's this instead?"
Else-for is just shorthand for "well it wasn't that, so let's loop
over something".
Else-if is generally used for chaining, often effectively as an
advanced switch/match statement.
I've never actually seen else-for, but I imagine it would be used for:
if (!foo) {
} else for (i = 0; i < foo->bar; i++) {
}
I don't think this pattern has enough value to be acceptable as
shorthand. BUT, I didn't know it was a thing until now, so I'm
naturally biased against it.
On Wed, Aug 30, 2017 at 2:58 PM, <[email protected]> wrote:
> Let's keep the flames alive!
>
> Should we always put braces after an `else`, with the only exception being
> another `if`?
> Or should we also have exceptions for the other control structures (while,
> do, for, switch)?
>
> A.
> if (...) {
> ...
> } else {
> for (...) {
> ...
> }
> }
>
> B.
> if (...) {
> ...
> } else for (...) {
> ...
> }
>
> I can see arguments for&against both, so I'm not too sure which one should
> win. :-)
> WDYT?
> _______________________________________________
> dev-platform mailing list
> [email protected]
> https://lists.mozilla.org/listinfo/dev-platform
_______________________________________________
dev-platform mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-platform