What is the exact specification for block comments? It seems to be true that the first and the last lines have to start exactly with =begin
and =end
. But besides that, there is a little unclarity. Some descriptions say =begin
and =end
must be the only thing on the respective lines, but that does not seem to be true. Running Ruby 1.9.3 MRI, I get the following results.
Adding white space characters still seems to work:
=begin \t\t \t
This is not a Ruby command and should raise an exception if read.
=end \t\t\t \t\t\t\t
# => no problem
Furturemore, it seems that I can add an arbitrary string (not including "\n") after one or more space characters, and it is still okay:
=begin \t\t \tblah blah blah
This is not a Ruby command and should raise an exception if read.
=end \t\t\t \t\t\t\tThis is some scribble
# => no problem
I can put a line starting with =begin
in the middle of a block comment:
=begin
This is not a Ruby command and should raise an exception if read.
=begin
So as this one.
=end
# => no problem
But not a line that qualifies as the last line of the comment:
=begin
This is not a Ruby command and should raise an exception if read.
=end blah blah
So as this one.
=end
# => error
Is this specification, or an implementation-dependent behavior? For clarity, can someone describe in terms of regex the exact specification of a Ruby block comment syntax?