Harness reactive programming to build scalable and fault-tolerant distributed systems using Scala and Akka About This Book Use the concepts of reactive programming to build distributed systems running on multiple nodes Get to grips with the full ran
变长参数
传递的参数是可以改变的。
例如:
def sum(nums:Int * ) = {
var result = 0
for(num <- nums){
result += num
}
result
}
result 是返回值
因为是返回值,所以 在定义的时候别忘记有 = 。
如何传递 range 序列 ?
比如上面的传递 val s = sum(1 to 10) 这样子是不对的,此时需要使用 scala 特殊的语法将参数定义为序列,让 scala 解释器能够识别。
形如这样子: