Ruby/Language Basics/Comments
Материал из Wiki.crossplatform.ru
Версия от 17:59, 13 сентября 2010; ViGOur (Обсуждение | вклад)
Содержание |
Create comments in Ruby, using the # symbol.
# When you use # on a line, everything you place after the # will be ignored by Ruby, although you can read it. puts "Hello from Ruby." #Display the text!
Make sure trailing comments are far enough from the code
@counter # keeps track times page has been hit @siteCounter # keeps track of times all pages have been hit
Some valid examples of commenting in Ruby:
puts "2+2 = #{2+2}" # Adds 2+2 to make 4 # A comment on a line by itself
This block comment conceals several lines from the interpreter with =begin/=end:
=begin
This is a comment.
This is a comment, too.
This is a comment, too.
I said that already.
=end
What are Comments
A comment hides lines from the Ruby interpreter so that the lines are discarded or ignored. You can make a comment run over several lines, like this: # This is a comment. # This is a comment, too. # This is a comment, too. # I said that already.