Quick Quiz #2 - Semicolons - Solutions
-
- Posts: 55
- Joined: Wed Sep 18, 2013 10:06 pm
- Contact:
Quick Quiz #2 - Semicolons - Solutions
Please post your solutions and explanations to Quick Quiz #2 as a reply to this message.
Re: Quick Quiz #2 - Semicolons - Solutions
All - before it will compile to my satisfaction!
None - if you are not so picky.
Robert
None - if you are not so picky.
Robert
Re: Quick Quiz #2 - Semicolons - Solutions
It does not say "can (optionally)", it says "need to".How many semicolons need to be removed from the following code snippet before it will compile?
My answer is: none of the semicolons need to be removed.
I know that the semicolon is a separator of statements, not a terminator, and that the empty statement was introduced in the language in order to admit a semicolon before "ELSE", "END", etc.
So, although I have not tested, I think that it would be even possible to write:
Code: Select all
IF j = 0 THEN;;;
;;ELSE;;
;END;;;
Manuel
Re: Quick Quiz #2 - Semicolons - Solutions
I was gently criticising the question because what will compile is not the only merit criterion.
One might also want to give consideration to other factors, for example the Programming Conventions document that says
One might also want to give consideration to other factors, for example the Programming Conventions document that says
RobertSemicolons are used to separate statements, not to terminate statements. This means that there should be no superfluous semicolons.