@@ -2915,27 +2915,32 @@ <h3 id="Calls">Calls</h3>
2915
2915
< h3 id ="Passing_arguments_to_..._parameters "> Passing arguments to < code > ...</ code > parameters</ h3 >
2916
2916
2917
2917
< p >
2918
- If < code > f</ code > is variadic with final parameter type < code > ...T</ code > ,
2919
- then within the function the argument is equivalent to a parameter of type
2920
- < code > []T</ code > . At each call of < code > f</ code > , the argument
2921
- passed to the final parameter is
2922
- a new slice of type < code > []T</ code > whose successive elements are
2923
- the actual arguments, which all must be < a href ="#Assignability "> assignable</ a >
2924
- to the type < code > T</ code > . The length of the slice is therefore the number of
2925
- arguments bound to the final parameter and may differ for each call site.
2918
+ If < code > f</ code > is < a href ="#Function_types "> variadic</ a > with a final
2919
+ parameter < code > p</ code > of type < code > ...T</ code > , then within < code > f</ code >
2920
+ the type of < code > p</ code > is equivalent to type < code > []T</ code > .
2921
+ If < code > f</ code > is invoked with no actual arguments for < code > p</ code > ,
2922
+ the value passed to < code > p</ code > is < code > nil</ code > .
2923
+ Otherwise, the value passed is a new slice
2924
+ of type < code > []T</ code > with a new underlying array whose successive elements
2925
+ are the actual arguments, which all must be < a href ="#Assignability "> assignable</ a >
2926
+ to < code > T</ code > . The length and capacity of the slice is therefore
2927
+ the number of arguments bound to < code > p</ code > and may differ for each
2928
+ call site.
2926
2929
</ p >
2927
2930
2928
2931
< p >
2929
- Given the function and call
2932
+ Given the function and calls
2930
2933
</ p >
2931
2934
< pre >
2932
2935
func Greeting(prefix string, who ...string)
2936
+ Greeting("nobody")
2933
2937
Greeting("hello:", "Joe", "Anna", "Eileen")
2934
2938
</ pre >
2935
2939
2936
2940
< p >
2937
2941
within < code > Greeting</ code > , < code > who</ code > will have the value
2938
- < code > []string{"Joe", "Anna", "Eileen"}</ code >
2942
+ < code > nil</ code > in the first call, and
2943
+ < code > []string{"Joe", "Anna", "Eileen"}</ code > in the second.
2939
2944
</ p >
2940
2945
2941
2946
< p >
0 commit comments