Latest web development tutorials

Scala specified function parameter name

Scala function Scala function

Under normal circumstances the function call parameters, in accordance with the order parameter of the function definition when one passes. But we can also pass through the specified function parameter names, and does not require the order to function arguments, examples are as follows:

object Test {
   def main(args: Array[String]) {
        printInt(b=5, a=7);
   }
   def printInt( a:Int, b:Int ) = {
      println("Value of a : " + a );
      println("Value of b : " + b );
   }
}

Implementation of the above code, the output is:

$ scalac Test.scala
$ scala Test
Value of a :  7
Value of b :  5

Scala function Scala function