Comments
In this page:
Comments
A // starts a single-line comment in Scala, and /* ... */ wraps a multi-line comment block. Scaladoc comments, written as /** ... */, are used to generate API documentation and can appear above classes, objects, and methods. Comments should explain non-obvious reasoning, not restate what the code already makes clear.
Note: /** ... */ (double-star) Scaladoc comments are recognized by documentation-generation tools, unlike plain /* ... */ comments.
Example: Comments
object Main extends App {
// This is a single-line comment
val x = 10 // inline comment after code
/* This is a
multi-line comment block */
/** Scaladoc comment describing this value. */
val y = 20
println(x + y)
}
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 8 topics to unlock
0/8 topics done
Complete these topics first: