Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt

Use this file to discover all available pages before exploring further.

A block comment in Kotlin is a lexical construct used to instruct the compiler to ignore a specific span of text. It is delimited by the /* character sequence at the beginning and the */ character sequence at the end. The enclosed text can span multiple lines or be placed inline within a single statement. Standard Syntax
/*
  This text is ignored by the Kotlin compiler.
  It can span multiple lines.
*/

val result = 100 + /* inline block comment */ 50
Nested Block Comments Unlike Java and C++, Kotlin’s lexical analyzer supports nested block comments. When the compiler encounters a nested /*, it increments an internal depth counter and requires a corresponding */ to decrement it before terminating the outer comment. This prevents premature termination errors when commenting out large sections of code that already contain existing block comments.
/*
  Outer comment begins.

  /*
    Inner nested comment.
    The compiler tracks this depth.
  */

  Outer comment concludes.
*/
KDoc Distinction A block comment that begins with an extra asterisk (/**) is structurally distinct and treated as a KDoc comment. While it shares the same termination syntax (*/) and nesting capabilities as a standard block comment, its contents are parsed into an Abstract Syntax Tree (AST) by the Kotlin documentation engine (Dokka) to generate API references.
/**
 * KDoc block comment.
 * Parsed for structural documentation rather than strictly ignored.
 */
Master Kotlin with Deep Grasping Methodology!Learn More