this post was submitted on 10 Feb 2024
207 points (96.4% liked)

196

16509 readers
2489 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
207
Antimemes rule (lemmy.dbzer0.com)
submitted 9 months ago* (last edited 9 months ago) by [email protected] to c/[email protected]
 
you are viewing a single comment's thread
view the rest of the comments
[–] 9point6 63 points 9 months ago (4 children)

Anything but K&R is psychopathic, fight me

[–] [email protected] 28 points 9 months ago* (last edited 9 months ago) (2 children)

Allman if the condition is very long

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

vs

while(isSomething
    && isSomethingElse
    && nFoo < 10) {
    bla();
    bla();
}
[–] 9point6 54 points 9 months ago (1 children)

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

while (
    isSomething 
    && isSomethingElse
    && nFoo < 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

[–] nnullzz 11 points 9 months ago

This is the way.

[–] [email protected] 10 points 9 months ago

Allman is allright, anything else I agree.

[–] Frozzie 6 points 9 months ago

No no, you're speaking the truth

[–] [email protected] 3 points 9 months ago

Isn't Java like this? Everybody I know who codes java does it like this and I've been trying to follow along despite it looking stupid.