Reading Time: < 1 minuteCommenting code is a good practice, helping you and your fellow programmers understand and maintain the code.
Whatever you write in the comment is ignored by Kotlin compiler.
There are 2 types of comment in Kotlin
- Single-line Comments
- Mulit-line Comments
To write single line Kotlin comment, you need to user //.
… and a complete example.
What will happen when // is removed from the program?
The second println will be pritned out as well.
There are 2 ways to do it.
In this case, you will have to write // in each line before writing the comment.
What if you have to write 20 lines of comment?
It is not a good idea of writing multiple lines of comment in Kotlin using //.
The good way in this case is /*..*/
I hope the description was understandable and clear. But if you have still questions, then leave me comments below! 😉
Have a nice a day! 🙂