Re: [go-nuts] tests for variadic functions

2018-05-23 Thread Josh Humphries
The syntax you are looking for is: max(test.vals...) The ellipsis indicates that the var args are the *contents* of the slice, as opposed to trying to pass the slice as if it were just a single element of the var args. *Josh Humphries* jh...@bluegosling.com On Wed, May 23, 2018 at 7:09

Re: [go-nuts] tests for variadic functions

2018-05-23 Thread Caleb Spare
The struct field should be vals []int and then you'd call max(test.vals...).​ On Wed, May 23, 2018 at 4:09 PM Alex Dvoretskiy wrote: > How do you write test for variadic functions? > > For example I have function: > > func max(vals ...int) int { > m := 0 > for _, v := range vals { > if v > m { >