Ok so this won't take very long, so it only gets half a number, but I think it is important to go over the concept of how to comment out code. If you look at the picture from the previous example, you may be wondering what all of that green text is for. That text is commented out. That means that to the compiler, it is as if it isn't even there. This becomes really useful when you want to start making comments about different things you are doing in code so that when you come back, your intentions are more transparent.
You may not realize this yet, but there will come times when you go back and look at some code that you wrote and you won't have a clue what is going on. Comments are an important and essential way of making code easy to read and understand.
There are two ways that you comment out code:
// Text - Two forward slashes indicate that you want to comment out just one line of code. Putting these two slashes at the beginning, or middle of a line will comment out and make green all the code to the right of this declaration.
/* Text */ - This notation allows you to comment out multiple lines of code without having to do a bunch of slashes. It is like the shortcut for mass-commenting out.
To better internalize these concepts, look over the image below:
No comments:
Post a Comment