On Thu, Jan 26, 2017 at 7:45 AM,  <joeymille...@gmail.com> wrote:
> var s [2]string
> s[0] = "PASS"
> s[1] = "FAIL"
> fmt.Println(strings.Join(s, ","))
>
>
> The following code fails, I know this works with a slice, But I am a newbie
> to go and I am trying to figure out the reason why this fails? Does it have
> something to do with cap or len?

It's simply that an array is not a slice.  The function strings.Join
is written to expect a slice, and you are trying to pass an array.
You need to write `strings.Join(s[:], ",")`.  That uses a slice
expression to get a slice of the array.  It may help to read
https://blog.golang.org/slices .

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