English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
In general, when calling a function, the parameters are passed one by one in the order of the function definition. However, we can also pass parameters to the function by specifying parameter names without following the order, as shown in the following 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 is as follows:
$ scalac Test.scala $ scala Test Value of a : 7 Value of b : 5