Note that the semi-colon that was previously doing nothing has now turned into an error once we add an elsif or else stanza. Leaving the semi-colon out means that you don't need to delete anything if your control structures need to change.
(Apologies if jaiku eats my formatting; it would be lovely to have a preview button.)
4 comments so far
I never use a semicolon after a block brace. It doesn't look as "elegant" imho.
1 year, 7 months ago by SlippingAway
There's no need for a semicolon after a block brace. It just turns into a no-op.
1 year, 7 months ago by strredwolf
I've never used it, ever...
1 year, 7 months ago by fluff
The big reason not to use a semi-colon is that it can trip you up later on. Let's say that you have some code like this:
if ($foo < 3) { print "Too small\n"; };
and you then go to add to the conditional:
if ($foo < 3) { print "Too small\n"; }; elsif ($foo > 7) { print "Too big\n"; }
Note that the semi-colon that was previously doing nothing has now turned into an error once we add an elsif or else stanza. Leaving the semi-colon out means that you don't need to delete anything if your control structures need to change.
(Apologies if jaiku eats my formatting; it would be lovely to have a preview button.)
1 year, 6 months ago by pjf