Comments
In this page:
Comments
A # starts a single-line comment in Ruby, and everything after it on that line is ignored. Multi-line comments use =begin and =end, though single-line # comments are far more common in practice. Comments should explain non-obvious reasoning, not restate what the code already makes clear.
Note: Most Ruby style guides discourage =begin/=end blocks in favor of multiple # lines.
Example: Comments
# This script demonstrates comments
puts "Hello!" # inline comment after code
=begin
This is a multi-line comment block,
though single-line # comments are more idiomatic.
=end
puts "Still running"
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: