The ellipsis has two uses in Go, one is in variadic parameters, the other 
is in the slice append operator. It is essentially an iterator that takes a 
list and turns it into a slice (parameters) or takes a slice and turns it 
into a recursive iteration (append). Parameters with the ellipsis are 
addressed inside the function as a slice of the type after the ellipsis.

The uses for it are not at all consistent but they are kinds of iteration 
operators, one bundles a slice, the other unbundles it.

On Thursday, 25 April 2019 21:35:16 UTC+2, Andrew Price wrote:
>
> Hey folks,
>
> A colleague wrote this:
>
> func (l *Logger) log2StdFormatted(level string, msgOrFormatOrArg 
>> interface{}, args... interface{}) (formatted string) {
>
>
> Note the position of the space *between* the ... and interface{}, not 
> before the ...
>
> [btw does "..." have an easy-to-search-for name?]
>
> It compiles, I think, but what what does it mean? My braincell hurts.
>
> I 'corrected' this and now my colleague is complaining :(
>
> Andy
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to