scala中def
Scala def关键字 (Scala def keyword)
The def keyword in Scala is used to declare functions and methods in Scala. Scala being ignorant on the data types does the same with the return type of a function. Declaring and defining a function in Scala does not strictly require a return type. The def keyword usage makes the Scala program more flexible.
Scala中的def关键字用于在Scala中声明函数和方法。 对数据类型无知的Scala与函数的返回类型相同。 在Scala中声明和定义函数并不严格要求返回类型。 def关键字的使用使Scala程序更加灵活。