Single-line comments

As the name implies, these comments span a single line. Single-line comments are started with two backslashes (//). Upon compilation of your program, all characters coming after these slashes are ignored. Consider the following code:

val b: Int = 957 // This is a single line comment// println(b)

The value held by b is never printed to the console because the function that performs the printing operation has been commented out.

Get Kotlin Programming By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.