Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What inspired Ruby's =begin .. =end comment block syntax?

Tags:

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?

like image 278
dan Avatar asked Jan 08 '12 03:01

dan


People also ask

How do you comment out a block of code in Ruby?

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!"

Is used to start the comment in 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.

What are magic comments in Ruby?

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.

How do you comment multiple lines in Ruby Mac?

UPDATE: Also in TextMate, assuming you have the right language selected, Cmd + / will toggle commenting every line in a selection regardless of language.


1 Answers

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

like image 193
Sam Avatar answered Oct 01 '22 18:10

Sam