Ladan
Ladan

Reputation: 9

The usage of multiline comments in Kotlin

Is it just a luxury os it there a real usage of multiline comments in Kotlin?

/* This is a comment.

 /* And inside it
 is
 another comment.
 */

 Back to the first.
 */

Upvotes: 0

Views: 1053

Answers (1)

Tenfour04
Tenfour04

Reputation: 93581

I think you're asking about multi-line comments within multi-line comments, right?

Imagine you have a big function that has a multi-line comment inside it. Then you want to comment out this whole function. You can surround it with /* and */ and it will correctly comment the whole function even though there is a */ inside it. It can detect that it's an interior comment by its preceding */. This is why it's necessary for a multi-line comment to allow nested multi-line comments within itself.

Upvotes: 1

Related Questions