Why use a multi-line comment when you can just use a single-line comment if neither one actually shows up in a code? Any examples of each use? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why use a multi-line comment when you can just use a single-line comment if neither one actually shows up in a code? Any examples of each use?

//single-line comment vs. /*multi-line comment*/

30th Aug 2016, 11:17 PM
Danielle Gaston
Danielle Gaston - avatar
4 Answers
+ 4
// fix later /* I should probably fix this later at some point in the future, some of these things i need to fix are; collision collecting credentials optimizations on the boot loader */
30th Aug 2016, 11:23 PM
Null Void
Null Void - avatar
+ 2
Comments are ignored by the compiler, but it doesn't mean they are useless. Use them to add notes to your codes: explanations of how a function work or what a variable is used for, ideas for improvement, TODOs, temporary removal of code, etc. They can be a great source of info for the ones reviewing your code (including you). Use the multiline one when you want to put a big block of comment. That way, you don't have to put // at the beginning of each line.
30th Aug 2016, 11:59 PM
Zen
Zen - avatar
+ 2
Besides commenting... I often use /* */ to tell the compiler to ignore entire blocks of code that I refuse to delete or keep as back-up, within a text file, in case I accidentally wreck a code block I am working on. /* */ is also good for troubleshooting purposes because it can be used to quickly hide multiple lines or blocks of code from the compiler to help isolate and locate faulty code within your program. There are compilers that can do this for you with a simple click, I use Visual Studio, but I prefer practicing with old school methods because I am a purist.
31st Aug 2016, 12:09 AM
TylerFrost
TylerFrost - avatar
0
Thank you all for the help. I have a much better understanding now
31st Aug 2016, 1:25 AM
Danielle Gaston
Danielle Gaston - avatar