Concept Flow - Comments and documentation syntax
Start of code
Check line
Is comment?
Ignore
Next line
End
The program reads each line, ignores comments, attaches documentation to code, and executes code lines.
/** * This function prints a greeting */ fun greet() { // This is a comment println("Hello") }
| Step | Line Content | Type Detected | Action | Output/Effect |
|---|---|---|---|---|
| 1 | /** | Doc comment start | Start doc comment block | Begin doc capture |
| 2 | * This function prints a greeting | Doc comment line | Add to doc comment | Doc content stored |
| 3 | */ | Doc comment end | End doc comment block | Attach doc to function greet |
| 4 | fun greet() { | Code | Execute function start | Function greet defined |
| 5 | // This is a comment | Single-line comment | Ignore line | No effect |
| 6 | println("Hello") | Code | Execute print statement | Prints: Hello |
| 7 | } | Code | Execute function end | Function greet ends |
| 8 | End of code | Stop execution | Program ends |
| Variable | Start | After Step 1 | After Step 3 | Final |
|---|---|---|---|---|
| docComment | empty | started | attached to greet | attached to greet |
| output | empty | empty | empty | Hello printed |
Kotlin comments: // single-line comment ignored by compiler /* multi-line comment ignored */ /** documentation comment attached to code * used by tools */ Comments do not affect program output but help explain code.