Comment (computer programming): Difference between revisions

Content deleted Content added
Scripting: Combine perl and raku
Examples: Merge Ruby into scripting section
Line 367:
===Scripting===
 
A pattern in many [[scripting language]]s is to delimit a line comment with <code>#</code> and providevarying or no support for a block comment. Notable languages include: [[Bash (Unix shell)|Bash]], [[Raku (programming language)|Raku]], [[Ruby (programming language)|Ruby]], [[Perl]], [[Windows PowerShell|PowerShell]], [[Python (programming language)|Python]] and [[R (programming language)|R]].
 
An example in R:
Line 374:
# This is a comment
print("This is not a comment") # This is another comment
</syntaxhighlight>
 
====Block in Ruby====
A block comment is delimited by <code>=begin</code> and <code>=end</code> that start a line. For example:
 
<syntaxhighlight lang="ruby">
puts "This is not a comment"
# this is a comment
puts "This is not a comment"
=begin
whatever goes in these lines
is just for the human reader
=end
puts "This is not a comment"
</syntaxhighlight>
 
Line 753 ⟶ 767:
 
}
</syntaxhighlight>
 
====Ruby====
Inline comments in [[Ruby (programming language)|Ruby]] start with the # character.
 
To create a multiline comment, one must place "=begin" at the start of a line, and then everything until "=end" that starts a line is ignored. Including a space after the equals sign in this case throws a syntax error.
<syntaxhighlight lang="ruby">
puts "This is not a comment"
 
# this is a comment
 
puts "This is not a comment"
 
=begin
 
whatever goes in these lines
 
is just for the human reader
 
=end
 
puts "This is not a comment"
</syntaxhighlight>