1. Arbitrary multi parameters funcs
sum(1,2,3,4,5) = sum(1 to 5: _*)
the equal '=' can be ignored if there is none return val
1 def sum(args: Int*) = { 2 var result = 0 3 for(arg <- args) result += arg 4 result 5 }
scala Array Buffer to Java List:
1 import scala.collection.JavaConversions.bufferAsJavaList 2 import scala.collection.mutable.ArrayBuffer 3 val command = ArrayBuffer("ls","-al","/home/mike") 4 val pb = new ProcessBuilder(command)
reverse operation
1 import scala.collection.JavaConversion.asScalaBuffer 2 import scala.collection.mutable.Buffer 3 val cmd:Buffer[String] = pb.command()
Hash Map
1 val hs01 = Map("s01" -> 342342,"s02" -> 4245) 2 hs01.getOrElse("s01",0)