It works with or without the body brackets... apparently. Time to see what he means by magic numbers

You may know this already - braces, or curly braces, are only required when you have multiple statements following a conditional or loop statement.

if/for/do/while/… ()
// do something

if/for/do/while/… () {
// do something
// do something else
// do another thing
// etc.

Probably applies to nearly anything, however, most other places (e.g., class declaration/definition) you should use them just for clarity. You can also just simply use them for clarity, whether needed or not.

1 Like

Privacy & Terms