Home > Articles

This chapter is from the book

Leaving Yourself Comments

In the previous code, you may notice the sentence -- Destroys whatever touches the part. This is a comment. Comments begin with two dashes. Anything on the same line as the dashes doesn’t affect the script.

Coders use comments to leave notes to themselves and others about what the code does. Trust us: When you haven’t looked at a piece of code in months, it’s very easy to forget what it does.

The following code shows what it might look like to add a comment at the top of the script you wrote earlier in this hour:

-- What do I want for dinner?
print("I want lots of pasta!")

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.