Scala 方法返回值

Scala 方法的最后一句代码就是该方法的返回值,返回值可以是一个元组Tuple,如:

def createActorSystem(
    name: String,
    host: String,
    port: Int,
    conf: SparkConf,
    securityManager: SecurityManager): (ActorSystem, Int) = {
  val startService: Int => (ActorSystem, Int) = { actualPort =>
    doCreateActorSystem(name, host, actualPort, conf, securityManager)
  }
  Utils.startServiceOnPort(port, startService, conf, name)
}

返回的是Utils.startServiceOnPort的返回值,startServiceOnPort将返回一个元组的信息,所在在调用的时候:

val (actorSystem, boundPort) = AkkaUtils.createActorSystem(systemName, host, port,
  conf = conf, securityManager = securityMgr)


你可能感兴趣的:(【Scala】编程指南)