Our own code can quickly become difficult to understand when we return to it—sometimes only a few hours later! For this reason, it’s often useful to leave a note or reminder in our code for our future selves or other developers.
In order to tell the computer that some of the text in our program is only meant for notes (and shouldn’t be executed), we can designate parts of our code as comments. Comments can explain what the code is doing, leave instructions for developers using the code, or add any other useful annotations.
There are two types of code comments in Emojicode:
A single line comment will comment out a single line and is denoted by
💭 preceding it:
💭 Prints "hi" 😀 🔤hi🔤❗️
💭 comments out any code that follows it (until the end of the line), so you can also use one after a line of code:
😀 🔤hi🔤❗️ 💭 Prints "hi"
A multiline comment will comment out multiple lines and is denoted by
💭🔜 to begin the comment, and
🔚💭 to end the comment:
💭🔜 This is all commented out. None of this is going to run! 🔚💭
Let’s try writing two comments.
Somewhere in the program, add a single line comment with today’s date.
Add a multiline comment that explains how you are feeling.