this post was submitted on 10 Feb 2024
0 points (NaN% liked)

196

16423 readers
1970 users here now

Be sure to follow the rule before you head out.

Rule: You must post before you leave.

^other^ ^rules^

founded 1 year ago
MODERATORS
0
Antimemes rule (lemmy.dbzer0.com)
submitted 8 months ago* (last edited 8 months ago) by moosetwin@lemmy.dbzer0.com to c/196@lemmy.blahaj.zone
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] bort@feddit.de 0 points 8 months ago* (last edited 8 months ago) (1 children)

Allman if the condition is very long

while(isSomething
    && isSomethingElse
    && nFoo < 10)
{
    bla();
    bla();
}

vs

while(isSomething
    && isSomethingElse
    && nFoo < 10) {
    bla();
    bla();
}
[โ€“] 9point6@lemmy.world 1 points 8 months ago

Hmm, I think the condition gets newlined and you K&R on the closing parenthesis IMO:

while (
    isSomething 
    &amp;&amp; isSomethingElse
    &amp;&amp; nFoo &lt; 10
) {
    blah();
    blah();
}

You could also keep isSomething on the first line too, but I think it's nice to keep the whole multiline condition at the same indent width