How to comment multiple lines in ruby?
+3
A:
#!/usr/bin/env ruby
=begin
Between =begin and =end, any number
of lines may be written. All of these
lines are ignored by the Ruby interpreter.
=end
puts "Hello world!"
The MYYN
2010-06-07 13:12:57
+5
A:
#!/usr/bin/env ruby
=begin
Every body mentioned this way
to have multiline comments.
=end
puts "Hello world!"
<<-DOC
Also, you could create a docstring.
which...
DOC
puts "Hello world!"
"..is kinda ugly and creates
a String instance, but I know one guy
with a Smalltalk background, who
does this."
puts "Hello world!"
##
# most
# people
# do
# this
__END__
But all forgot there is another option.
Only at the end of a file, of course.
Konstantin Haase
2010-06-07 16:25:40
+1 for comprehensiveness
rampion
2010-06-07 18:07:11
A:
Despite the existance of =begin and =end, the normal and more correct way to comment is to use #'s on each line. If you read the source of any ruby library, you will see that this is the way multi-line comments are done in almost all cases.
ReinH
2010-06-08 18:24:08