Tutorials Point


  Ruby Basics
  Ruby Advanced
  Ruby Useful References
  Ruby Useful Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

Ruby Comments


previous next AddThis Social Bookmark Button


Comments are lines of annotation within Ruby code that are ignored at runtime. A single line comment starts with # charcter and they extend from # to the end of the line as follows:

#!/usr/bin/ruby -w

# This is a single line comment.

puts "Hello, Ruby!";

Ruby Multiline Comments

You can comment multiple lines using =begin and =end syntax as follows:

#!/usr/bin/ruby -w

puts "Hello, Ruby!";

=begin
This is a multiline comment and con spwan as many lines as you
like. But =begin and =end should come in the first line only. 
=end

Make sure trailing comments are far enough from the code that it is easily distinguished. If more than one trailing comment exists in a block, align them. For example:

@counter      # keeps track times page has been hit
@siteCounter  # keeps track of times all pages have been hit


previous next Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names