• bort@feddit.de
      link
      fedilink
      arrow-up
      28
      ·
      edit-2
      10 months ago

      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
        link
        fedilink
        arrow-up
        53
        ·
        10 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

    • /home/pineapplelover@lemm.ee
      link
      fedilink
      arrow-up
      3
      ·
      10 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.