Scala Specifying Function Argument Names
Generally, when calling a function, the arguments are passed in the order in which the parameters are defined in the function. However, we can also pass arguments to a function by specifying the argument names, without having to follow the order. Here is an example:
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 );
}
}
After executing the above code, the output will be:
$ scalac Test.scala
$ scala Test
Value of a : 7
Value of b : 5