do i need the ; after end or not. it works both ways??
· #1sometimes i write end; and sometimes end and it compiles both ways
is the semicolon decoration
sometimes i write end; and sometimes end and it compiles both ways
is the semicolon decoration
Not decoration, but you've noticed something real.
A semicolon separates statements. It doesn't end them. So before an end it's optional, because there's nothing after it to separate from:
begin
WriteLn('one');
WriteLn('two') // no semicolon needed here, "end" comes next
end;Both compile. Most people write the semicolon anyway, so that adding a line later doesn't break anything.
The places where it is not optional:
| Where | Semicolon? |
|---|---|
| Between two statements | required |
Before end |
optional |
Before else |
forbidden |
After the final end of a program |
it's a period: end. |
Read the error message. Then read it again.
whoa
so the last one is a dot
i have been putting a semicolon there and then deleting things until it compiled
That is, in fairness, how most of us learned.
Pete · thirty years of begin and end
"It compiled on my machine."
THE PROGRAM ENDS WITH A PERIOD BECAUSE IT IS A SENTENCE
that is actually kind of beautiful. sorry
SORRY ABOUT THE CAPS
For once I have nothing to add. Mark the calendar.
Forum rules 1 to 10 apply. Yes, to you.