Forgot username/password? Don't have an account?
Login with Facebook
Home » Courses » Coding Basics 1 » Multi line Comments
Subscribe for updates.
* New to us? log in with Facebook and get a free day pass

Multi line Comments

In every developers life there comes a time where he just wants to comment a few things out without deleting them. You already know how to comment line by line but wouldn't it be nicer (for you and your fingers) if you could cancel out a full block of code?

We have already studied commenting in earlier videos and discussed the single line comment in detail. We won't go in detail about this but will just have a quick review of the previous video before moving ahead to multi-line comments.

We all know that at times we need to hide part of a lengthy piece of code. As we said earlier, we do not want to delete it – just hide it through commenting it out so we can use it again when required. This is the main reason we use the concept of comments, and we use the single line comment to hide one line in the program by placing // before the line.

Now let's dive into multi-line comments. We have studied how to hide single line of code which is not required. What if there are multiple lines to be hidden for future use? One option is to use single line comments for each unwanted line of code. This is a good answer and a correct one, but is it the easiest or smartest way to do it? If you need to comment out a large block of code, will you still use the same process? There must be a better solution.

And presto – there is! The best way to save your fingers and comment out multiple lines in code is to use Multi-line comments. The way we create multi-line comments is by opening and closing the block of code using two symbols: /* to open a comment and */ to close one. This will comment out any number of lines between /* and */. This way you can skip about 50 or 100 lines within 5 seconds. You must close a multi-line comment, contrary to the single line comment. Multi-line comments are like parenthesis: if you open one you must close it as well.

Comments are more than just to ignore code, as we said before. Comments are a very powerful and useful documenting feature from "by the way" notes to yourself all the way to really advanced commenting structures known as ASDocs – those are comments that have a structure, but are not used as part of the code. They actually create Flash help documentation.

Got A Question?

'I love being Prime'

Have a question but don't want to ask it publicly? If you are a prime member just ask right here and we will get back to you within 48 hours. Not prime yet? no worries you can ask publicly below.

Act now while we have available seating

Our on line school is private, affordable and interactive with trainer support.
Act now save your seat before someone else takes yours.
Act now