D
D
Daniil Demidko2015-12-20 09:47:28
C++ / C#
Daniil Demidko, 2015-12-20 09:47:28

Do you put curly braces?

I understand the question is strange, but I don’t know what is better when you need to perform one action with a condition.
For example:

if(any)
     {
            // строка кода
     }

Or like this:
if(any)
          // строка кода

In Sroustrup's examples, nothing on this topic is clear - in some cases he uses curly braces after the condition, even if only one action needs to be performed, in others he does not.
Beauty or conciseness?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
aminought, 2015-12-20
@Daniro_San

The rule of good form is the setting of curly braces in any case. For inspiration, you can read this article: The exceptional beauty of Doom 3 source code

S
sim3x, 2015-12-20
@sim3x

if(any) {
    // строка кода
}

N
Noortvel, 2015-12-20
@Noortvel

if(any) // строка кода ;
?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question