Comments are very important in your programs. They are used to tell you what something does in English, and they also are used to disable parts of your program if you need to remove them temporarily. Here's how you use comments in Ruby:
1 2 3 4 5 6 7 8 9 | # A comment, this is so you can read your program later.
# Anything after the # is ignored by Ruby.
puts "I could have code like this." # and the comment after is ignored
# You can also use a comment to "disable" or comment out a piece of code:
# puts "This won't run."
puts "This will run."
|
$ ruby ex2.rb
I could have code like this.
This will run.
$