this post was submitted on 10 Feb 2024
223 points (99.6% liked)

196

16822 readers
610 users here now

Be sure to follow the rule before you head out.

Rule: You must post before you leave.

^other^ ^rules^

If you have any questions, feel free to contact us on our matrix channel.

founded 2 years ago
MODERATORS
223
Antimemes rule (lemmy.dbzer0.com)
submitted 1 year ago* (last edited 1 year 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
[–] 9point6@lemmy.world 67 points 1 year ago (4 children)

Anything but K&R is psychopathic, fight me

[–] bort@feddit.de 28 points 1 year ago* (last edited 1 year 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@lemmy.world 54 points 1 year ago (1 children)

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

[–] nnullzz@lemmy.world 11 points 1 year ago

This is the way.

[–] isVeryLoud@lemmy.ca 10 points 1 year ago

Allman is allright, anything else I agree.

[–] Frozzie@lemmy.world 6 points 1 year ago

No no, you're speaking the truth

[–] pineapplelover@lemm.ee 3 points 1 year 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.