Scala函数定义:
def 函数名(参数列表,...):返回结果类型={},下面给出一个max函数
def max(a: Int,b: Int):Int ={
if(a > b)
a
else
b
}
var maxValue = max(6,10)
println("max(6, 10) the max maxValue is :" + maxValue )
println("max(6, 10) the max is :" + max(6,10) )
返回结果是较大的值
max(6, 10) the max maxValue is :10
max(6, 10) the max is :10