Sunday, 2 June 2013

A line comment acts like a newline

A line comment acts like a newline

I'm reading the Go language specification. The section on comments states:
Line comments start with the character sequence // and stop at the end of the line. A line comment acts like a newline.
What is the point of specifying that a line comment acts like a newline? Couldn't line comments simply act like empty strings?
Lines (except the last) end in a newline anyway, so any line (except the last) will act like two consecutive newlines. If the last line has a line comment, then it can also safely act like an empty string.

No comments:

Post a Comment