ブロックコメントの正確な仕様は何ですか?最初と最後の行は正確にとで始まらなければならないのは本当のよう=begin
です=end
。しかし、それ以外に、少し不明確な点があります。いくつかの説明は、それぞれの行で唯一のものでなければならないと言っ=begin
て=end
いますが、それは真実ではないようです。Ruby 1.9.3 MRIを実行すると、次の結果が得られます。
空白文字の追加は引き続き機能するようです。
=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
さらに、1つ以上のスペース文字の後に任意の文字列(「\ n」を含まない)を追加できるようですが、それでも問題ありません。
=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
=begin
ブロックコメントの真ん中に行を置くことができます:
=begin
This is not a Ruby command and should raise an exception if read.
=begin
So as this one.
=end
# => no problem
ただし、コメントの最後の行と見なされる行ではありません。
=begin
This is not a Ruby command and should raise an exception if read.
=end blah blah
So as this one.
=end
# => error
この仕様ですか、それとも実装に依存する動作ですか?明確にするために、誰かが正規表現の観点からRubyブロックコメント構文の正確な仕様を説明できますか?