In Scala, the named arguments are used to pass values in a function using a different order. Named arguments function calls are different from the regular functions calls.
Let us understand the named function which will show the function with named arguments. Save the program with functionexample.scala name and run it from the terminal by using scala functionexample.scala command(refer screenshot).
object namedfunction {
def main(args: Array[String]) {
printnamedfunction(x = 100, y = 150);
}
def printnamedfunction( y:Int, x:Int ) = {
println("Value of y : " + y );
println("Value of x : " + x );
}
}
Output
Click Here To Download Code File.