Scala分号

Scala分号 (Scala semicolons)

A semicolon or semi-colon (;) is a punctuation mark in programming, it is used to separate multiple lines of code. It is common in major programming languages like C, C++, Java, Pascal. In modern programming languages like Python, Scala.

分号或分号 ( ; )是编程中的标点符号,用于分隔多行代码。 它在C,C ++,Java,Pascal等主要编程语言中很常见。 在现代编程语言(如Python,Scala)中。

The semicolon is treated as the end of line statement. It treats it as the end of the expression, if not the expression can continue to the next line. But, in Scala, the end of the line is treated as the end of the expression. This means the user does not need to compulsorily use the semicolon (;) statement.

分号被视为行语句结尾 。 它将其视为表达式末尾 ,否则表达式可以继续到下一行。 但是,在Scala中,该行的结尾被视为expression的结尾 。 这意味着用户不需要强制使用分号 ( ; )语句。

Syntax:

句法:

    Code with a semicolon :     var a : int = 3445; 
    Code without semicolon:     var a : int = 3445

Example:

例:

object MyClass {
      def main(args: Array[String]) {
         println("This statement is executed with semicolon");
         println("This statement is executed without semicolon")         
      }
   }

Output

输出量

This statement is executed with semicolon
This statement is executed without semicolon

Code logic:

代码逻辑:

The code here has two print statements one print statement ends with a semicolon and second without semicolon. Both lines are valid and print the given strings.

此处的代码有两个打印语句,一个打印语句以分号结尾,第二个不带分号。 这两行均有效,并打印给定的字符串。

翻译自: https://www.includehelp.com/scala/semicolons-in-scala.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值