Concept

What curly-bracket convention should be used with conditional statements?

ComputerScienceOne / Computing a Logarithm

"Another convention that we’ve used in our code is where we have placed the curly brackets. First, if a conditional statement is bound to only one statement, the curly brackets are not necessary. However, it is best practice to include them even if they are not necessary and we’ll follow this convention. Second, the opening curly bracket is on the same line as the conditional statement while the closing curly bracket is indented to the same level as the start of the conditional statement. Moreover, the code inside the code block is indented. If there were more statements in the block, they would have all been at the same indentation level."

Related Ideas

What curly-bracket convention should be used with conditional statements? | ComputerScienceOne | Bifalgorithm | Bifalgorithm