I know that a lot of Ruby was inspired by Perl (e.g. STDIN as a global constant) or Unix shell (e.g. the <<END
heredoc syntax). But I don't know where the block comment syntax comes from. The syntax:
=begin This is a comment line it explains that the next line of code displays a welcome message =end
Where does this come from? My knowledge of Perl is sketchy. Is it Perl?
Single line comments in a Ruby script are defined with the '#' character. For example, to add a single line comment to a simple script: # This is a comment line - it explains that the next line of code displays a welcome message print "Welcome to Ruby!"
The Ruby single-line comment begins with the # character and ends at the end of the line. Any characters from the # character to the end of the line are completely ignored by the Ruby interpreter. The # character doesn't necessarily have to occur at the beginning of the line; it can occur anywhere.
Magic Comments. While comments are typically ignored by Ruby, special “magic comments” contain directives that affect how the code is interpreted. Top-level magic comments must appear in the first comment section of a file. NOTE: Magic comments affect only the file in which they appear; other files are unaffected.
UPDATE: Also in TextMate, assuming you have the right language selected, Cmd + / will toggle commenting every line in a selection regardless of language.
yes, this is Perl
Perl uses
=begin This is a comment line it explains that the next line of code displays a welcome message =cut
have a look here: http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(syntax)#Comments
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With