3 ms·
One way round this is to put single statement ifs on a single line: if (x) then(); If you add another statement to the if, its obvious from the indent tha
by papaf 10y ago
One way round this is to put single statement ifs on a single line:
if (x) then();
If you add another statement to the if, its obvious from the indent that you need to use braces.
- petre 10y agoYup, I always do this when writing JavaScript or other languages that allow prefix single statements with or without braces. Otherwise I use braces if the statement is too long to fit in the editor w/o forcing you to scroll. Perl only allows postfixed single statements w/o braces, so you're safe: say "yes" if $condition; if ($condition) { say "yes"; $affirmative++; }