35
jobylie
6y

This is how my prof uses braces:

If () {
test;
} else {
test2;
}

He uses it as an example of how to use line breaks properly.

Comments
  • 9
    Does he really uses If with capital I? 😓
  • 34
    I like your professors braces. But he could use some indentation
  • 10
    This is how I do it as well.
  • 7
    @Olverine not giving the else a new line should be illegal!
  • 15
    Uh, so in other words he uses standard java indentation?
  • 11
    As long as there are braces and they are consistent within the project, it's fine.
  • 4
    @Alice ok this makes sense. Probably looks ugly to me bc I am used to doing it differently
  • 3
    @jobylie you are right to assume different coding sryles for different programming languages, also depending on the coding style emphasis of the repository
  • 4
    That's completely okay, only indentation is missing.
  • 7
    This is what I do. With proper indentation of course.
    Putting an 'else' on its own line just waists space
  • 3
    @Kalex just what we were discussing the other day...some people just like to watch the world burn!
  • 1
    @Alice braces on a separate line is the standard for C#. If I'm writing C#, I do it that way. If not, I use the braces like in the post (standard for Java, JS, CSS, etc.).

    All depends on the language standard!
  • 1
    Almost identical to how I write mine.
  • 1
    Switched to else in the same line some weeks ago. It's the best way (for me) because you clarify easier what the main if is
  • 1
    @akashvartak yes! Where are the code blocks???
  • 1
    Java without indentations 😓
  • 3
    Brace yourself for this guy!
  • 0
    Well I mean, Rust won't let you do it without, as this is the syntax;

    if condition {
    // lol
    }

    Using parens on the condition won't allow you to drop em, but you are encouraged to use inline if/elses in some places
  • 0
    @sharktits It's famous from K&R and the C book they wrote so it's called the K&R indentation and btw it's the right indentation.
Add Comment