Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Already good answers, but I can provide a slightly different perspective here: always use braces if there is a risk of getting into a pitfall. Examples (from C#, but the language is less relevant)...
Answer
#1: Initial revision
Already good answers, but I can provide a slightly different perspective here: always use braces if there is a risk of getting into a pitfall. Examples (from C#, but the language is less relevant). - omit if the inner instruction fits on a single line and an extra blank line is inserted after: if (some_condition_here) return; var x = call(param1, param2); - include if the inner instruction does not fit on a single line: if (some_condition) { var someResult = DoSomeSpecialProcessingWithLotsOfParams( param1, param2, param3, param4); } Of course, it is easier to just always put them, but I see no point in having them for simple cases such as my first example.