The website uses cookies to optimize your user experience. Using this website grants us the permission to collect certain information essential to the provision of our services to you, but you may change the cookie settings within your browser any time you wish. Learn more
I agree
Summary | 19 Annotations
If a default parameter precedes a parameter with no default value, the default value can be used only by calling the function with named arguments:
2017/09/19 15:12
Overriding methods always use the same default parameter values as the base method. When overriding a method with default parameters values, the default parameter values must be omitted from the signature:
2017/09/19 15:12
But if a last argument lambda is passed to a function call outside the parentheses, passing no values for the default parameters is allowed:
2017/09/19 15:13
2017/09/19 15:13
When a function is called with both positional and named arguments, all the positional arguments should be placed before the first named one
2017/09/19 15:15
Variable number of arguments (vararg) can be passed in the named form by using the spread operator:
2017/09/19 15:16
foo(strings = *arrayOf("a", "b", "c"))
2017/09/19 15:16
Note that the named argument syntax cannot be used when calling Java functions, because Java bytecode does not always preserve names of function parameters.
2017/09/19 15:18
If a function does not return any useful value, its return type is Unit. Unit is a type with only one value - Unit. This value does not have to be returned explicitly
2017/09/19 15:19
// `return Unit` or `return` is optional
2017/09/19 15:19
Only one parameter may be marked as vararg
2017/09/19 15:22
spread operator (prefix the array with *):
2017/09/19 15:23
Inside a function a vararg-parameter of type T is visible as an array of T, i.e. the ts variable in the example above has type Array<out T>.
2017/09/19 15:26
Infix notation Functions can also be called using infix notations when They are member functions or extension functions; They have a single parameter; They are marked with the infix keyword.
2017/09/19 15:33
1 shl 2
2017/09/19 15:33
Local function can access local variables of outer functions (i.e. the closure)
2017/09/19 15:35
To be eligible for the tailrec modifier, a function must call itself as the last operation it performs
2017/09/19 15:43
and you cannot use it within try/catch/finally blocks.
2017/09/19 15:44
When a function is marked with the tailrec modifier and meets the required form, the compiler optimises out the recursion, leaving behind a fast and efficient loop based version instead:
2017/09/19 15:44