While they don’t actually do anything in a Ruby program, comments are critical for making code readable, especially complicated code. Ruby comments start with a # character and continue to the end of that line. If a line starts with #, then the entire line is a comment. If a line starts with code and then includes a # (outside of a quoted string or regular expression), then everything to the right of the # is considered a comment and ignored. For example:
# This whole line is a commentx = 2
# x is assigned the value 2, and the comment is ignored.
Comments are useful for humans, especially when you read someone else’s code or return to a project after a long while away, but Ruby will just ignore them.