I\'m reading some lecture notes of my C++ lecturer and he wrote the following:
- Use Indentation // OK
- Never rely on operator preced
I am using {} everywhere except a few cases where it's obvious. Single line is one of the cases:
if(condition) return; // OK
if(condition) //
return; // and this is not a one-liner
It may hurt you when you add some method before return. Indentation indicates that return is executing when condition is met, but it will return always.
Other example in C# with using statment
using (D d = new D()) // OK
using (C c = new C(d))
{
c.UseLimitedResource();
}
which is equivalent to
using (D d = new D())
{
using (C c = new C(d))
{
c.UseLimitedResource();
}
}