When to use the equals sign in a Scala method declaration?

前端 未结 7 1301
春和景丽
春和景丽 2020-11-28 05:09

With equals sign:

object HelloWorld {
  def main(args: Array[String]) = {
    println(\"Hello!\")
  }
}

Without equals sign:



        
7条回答
  •  青春惊慌失措
    2020-11-28 05:57

    You must use equals sign in call declarations except the definitions returning Unit.

    In this latter case, you may forgo the equals sign. This syntax may be deprecated, though, so it's best avoided. Using equals sign and declaring the return type will always work.

提交回复
热议问题