You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/md/kotlin.core/declarations.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -451,6 +451,11 @@ If one wants to mix named and positional arguments, the argument list must confo
451
451
452
452
> Note: in Kotlin version 1.3 and earlier, $PoN_i$ were restricted to positional arguments only.
453
453
454
+
If one needs to provide a named argument to a [variable length parameter][Variable length parameters], it can be achieved via either regular named argument `arg = arr` or a spread operator expression form `arg = *arr`.
455
+
In both cases type of `arr` must be a subtype of [$\ATS(\Array(\outV T))$][Array types] for a variable length parameter of type $T$.
456
+
457
+
> Note: in Kotlin version 1.3 and earlier, only the spread operator expression form for named variable length arguments was supported.
458
+
454
459
Kotlin also supports *default* parameters --- parameters which have a default value used in function invocation, if the corresponding argument is missing. Note that default parameters cannot be used to provide a value for positional argument *in the middle* of the positional argument list; allowing this would create an ambiguity of which argument for position $i$ is the correct one: explicit one provided by the developer or implicit one from the default value.
455
460
456
461
```kotlin
@@ -483,7 +488,7 @@ One of the parameters may be designated as being variable length (aka *vararg*).
483
488
A parameter list $(p_1, \ldots, \text{vararg }p_i: P_i = v_i, \ldots, p_n)$ means a function may be called with any number of arguments in the i-th position.
484
489
These arguments are represented inside function body $b$ as a value $p_i$ of type, which is the result of [*array type specialization*][Array types] of type $\Array(\outV P_i)$.
485
490
486
-
> Important: we also consider variable length parameters to have such types for the purposes of type inference.
491
+
> Important: we also consider variable length parameters to have such types for the purposes of type inference and named parameters.
487
492
> TODO(Something else?)
488
493
489
494
If a variable length parameter is not last in the parameter list, all subsequent arguments in the function invocation should be specified as named arguments.
Copy file name to clipboardExpand all lines: docs/src/md/kotlin.core/expressions.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -977,11 +977,11 @@ As described in [the function declaration section][Function declaration], functi
977
977
978
978
-Explicit receiver argument, used in calls with explicit receivers;
979
979
-Normal arguments, provided directly inside the parentheses part of the call;
980
-
-Named arguments in the form `identifier = value`, where `identifier` is a parameter name used at declaration-site of the function;
980
+
-[Named arguments][Named, positional and default parameters]in the form `identifier = value`, where `identifier` is a parameter name used at declaration-site of the function;
981
981
- [Variable length arguments][Variable length parameters], provided the same way as normal arguments;
982
982
-A trailing lambda literal argument, specified outside the parentheses (see [lambda literal section][Lambda literals] for details).
983
983
984
-
In addition to these, a function declaration may specify a number of default parameters, which allow one to omit specifying them at call-site, in which case their default value is used during the evaluation.
984
+
In addition to these, a function declaration may specify a number of [default parameters][Named, positional and default parameters], which allow one to omit specifying them at call-site, in which case their default value is used during the evaluation.
985
985
986
986
The evaluation of a function call begins with the evaluation of its explicit receiver, if it is present.
987
987
Function arguments are then evaluated **in the order of their appearance in the function call** left-to-right, with no consideration on how the parameters of the function were specified during function declaration.
@@ -1041,7 +1041,7 @@ It is allowed to mix spread arguments with regular arguments, all fitting into t
1041
1041
Spreadoperator expressions are not allowed in any other context.
1042
1042
See [Variable length parameter][Variable length parameters] section for details.
1043
1043
1044
-
The type of a spread argument must be a subtype of [$\ATS(T)$][Array types] for a variable length parameter of type $T$.
1044
+
The type of a spread argument must be a subtype of [$\ATS(\Array(\outV T))$][Array types] for a variable length parameter of type $T$.
1045
1045
1046
1046
>Example:for parameter `vararg a:Int` the type of a corresponding spread argument must be a subtype of `IntArray`, for parameter `vararg b:T` where `T` is a classifier type the type of a corresponding spread argument must be a subtype of `Array<outT>`.
Copy file name to clipboardExpand all lines: docs/src/md/kotlin.core/type-system.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -205,7 +205,7 @@ However, they are **not** related by subtyping; meaning one cannot pass a `Boole
205
205
206
206
> Note: specialized and non-specialized array types match modulo their iterator types, which are also specialized; `Iterator<Int>` is specialized to `IntIterator`.
207
207
208
-
*Array type specialization* $\ATS(T)$ is a transformation of a generic $\Array(T)$ type to a corresponding specialized version, which works as follows.
208
+
*Array type specialization* $\ATS(A)$ is a transformation of a generic $\Array(T)$ type to a corresponding specialized version, which works as follows.
209
209
210
210
* if $\Array(T)$ has a specialized version `TArray`, $\ATS(\Array(T)) = \texttt{TArray}$
211
211
* if $\Array(T)$ does not have a specialized version, $\ATS(\Array(T)) = \Array(T)$
0 commit comments