Is there any real reason to use "const"?

Ali Çehreli acehreli at yahoo.com
Mon Jan 24 18:22:47 UTC 2022


On 1/24/22 09:55, H. S. Teoh wrote:

 > as opposed to the verbosity of:
 >
 > 	if (x == y)
 > 	{
 > 		doSomething();
 > 	}
 > 	else if (y == z)
 > 	{
 > 		doSomethingElse();
 > 	}
 > 	else
 > 	{
 > 		doYetAnotherThing();
 > 	}

Luckily, humans are very adaptive and can be happy with the following 
style. ;)

if (x == y) {
   doSomething();

} else if (y == z) {
   doSomethingElse();

} else {
   doYetAnotherThing();
}

Especially note TABs are only for Makefiles. :p

But I can like the following no-brace formatting as well:

   if      (x == y) doSomething();
   else if (y == z) doSomethingElse();
   else             doYetAnotherThing();

Ali



More information about the Digitalmars-d mailing list