Scala评论 (Scala comments)
Comments are things that are readable by the programmer. They are added to the code to add an explanation about the source code. Commenting on a program to make it easier to understand by the programmer.
注释是程序员可以读取的东西。 它们被添加到代码中以添加有关源代码的说明。 对程序进行注释,使程序员更易于理解。
In Scala also comments are available. The comments in Scala are same as C++, Java and many other popular programming languages.
在Scala中,也提供注释。 Scala中的注释与C ++,Java和许多其他流行的编程语言相同。
There are two types of comments that can be added to a program:
可以将两种类型的注释添加到程序中:
Single-line comment
单行注释
Multiline Comment
多行注释
1)单行注释 (1) Single line comment)
It is the comment that has a span of an only single line. The line in which comment is started is commented.
该注释的跨度只有一行。 开始注释的行被注释。
Syntax:
句法:
// Single line code to be commented...
2)多行注释 (2) Multiline comment)
A multiline comment can span up to many lines based on its end literal. A multiline comment starts and ends with a literal and all the code inside that literal is treated as a comment.
根据多行注释的结束文字,它最多可以包含多行。 多行注释以文字开头和结尾,该文字内的所有代码均被视为注释。
Syntax:
句法:
/*
Multiline
Code to be commented
*/
Scala评论示例 (Example for Scala comments)
object MyClass {
def main(args: Array[String]) {
//printing Hello world! - this is single line comment
print("Hello world!");
/*
This is multiline comment -
Here, we are printing Hi friends!
*/
print("Hi friends!");
}
}
Output
输出量
Hello world!Hi friends!
翻译自: https://www.includehelp.com/scala/comments-in-scala.aspx