Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Scala Named Function Arguments

Scala Named Function Arguments

Scala functions Scala Functions

Normally, function arguments are passed one by one in the order defined. But you can also specify argument names and pass them out of order, as shown below:



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 );

   }

}

The output of the code above is:



$ scalac Test.scala

$ scala Test

Value of a :  7

Value of b :  5

Scala functions Scala Functions