Scala中的评论
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:
句法:
/* MultilineCode to be commented */Scala評論示例 (Example for Scala comments)
object MyClass {def main(args: Array[String]) {//printing Hello world! - this is single line commentprint("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
總結
- 上一篇: 字符串乘一个数_【思维拓展】三位数乘两位
- 下一篇: c++中cend end_vector