Do you know there are two ways of writing a block of code in a program? No? Let me show you π
This is war is one of the “Holy Wars” which consist of “Linux vs Mac vs Windows” , “Vim vs Emacs” , “GNOME vs KDE” blah blah π . Oh I forgot to mention, I wrote that code in Vim (my personal favorite editor, did I just start a holy war? Maybe IΒ started that right from the beginning of the post π . I think I should write a blog on the power of Vim as well )
Both method of writing the code is correct and compiler no way gives error on any one. Its just the way of writing the code and bothΒ have their own advantages.
Cuddled Braces tell the reader of the code that “Hey! The code block has started” and also helps in finding the statement for which the code block is all about.
Non-Cuddled Braces help the reader easily figure out the block of code and the code blocks which are nested within that block. They also help the reader to know the length of the code block as the braces are aligned.
My Opinion?
Well personally I prefer Non-Cuddled Braces over the Cuddled ones as they suit perfect for my eyes. What’s your take?