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)