On Fri, May 3, 2019 at 11:19 AM <lgod...@gmail.com> wrote:
>
> Am I missing something ??
> When u say :
> For any function F and some type T declared as    func F(x ...T) {}
> within F x will have type []T.  You can call F with a slice s of type []T as  
>  F(s...)
>
> Why is this needed ?? What's the point of using this "crypto-syntax"  rather 
> than just declaring the function as  func F(x [ ]T) { }

It permits passing a list of arguments without requiring them to be
explicitly assembled into a slice.

For example, the declaration of fmt.Printf is

func Printf(format string, a ...interface{}) (n int, err error)

The use of `...` is what permits you to write

fmt.Printf("%d %d", a, b)

rather than having to write

fmt.Printf("%d %d", []interface{}{a, b})

Ian

-- 
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