Comments are text within a program that are not executed by the compiler that may aid in describing what is happening in the code.
Single-line comments start with a
# I am a single line comment.
Multi-line comments start with
=begin and end with
=beginI am a multi line comment.I can take as many lines as needed.=end
The example below shows how single-line comments can be used in code.
# This example uses a loop to sum only the even valuescount = 0for i in 1..10 doif (i % 2 == 0)count += iendendputs count# Yields a total of 30
- christian.dinh2481 total contributions
- Anonymous contributorAnonymous contributor3077 total contributions