From bc087b50370a3c32c35ef026047c2fa9db9944d8 Mon Sep 17 00:00:00 2001 From: Pavel Kazlou Date: Sat, 31 Oct 2015 16:39:47 +0300 Subject: usage of named parameters --- scala.html.markdown | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'scala.html.markdown') diff --git a/scala.html.markdown b/scala.html.markdown index 192e03d7..bc8cd422 100644 --- a/scala.html.markdown +++ b/scala.html.markdown @@ -169,6 +169,12 @@ def sumOfSquaresShort(x: Int, y: Int): Int = x * x + y * y // Syntax for calling functions is familiar: sumOfSquares(3, 4) // => 25 +// You can use parameters names to specify them in different order +def subtract(x: Int, y: Int): Int = x - y + +subtract(10, 3) // => 7 +subtract(y=10, x=3) // => -7 + // In most cases (with recursive functions the most notable exception), function // return type can be omitted, and the same type inference we saw with variables // will work with function return values: -- cgit v1.2.3