Arrays Literals ( Rob Pike talk )

Hi,
i just came across a problem with an example illustrated by Rob Pike in his 3 days talk (2011).
the problem is:

cannot use &ar (type *[3]int) as type[3]*int in argument to f2

is it a change occurred on these last golang version or just something that im not aware of :slightly_frowning_face:

the code is:

package main

import (
	"fmt"
)

func f1(a [3]int) {
	fmt.Println(a)

}

func f2(a *[3]int) { //  fixed typo.
	fmt.Println(a)
}
func main() {
	var ar [3]int
	f1(ar)
	f2(&ar)
}

Oh Sorry gophers this was my mistake i just realized that i did a bad typo
[3]*int instead of *[3]int.

thank you anyway.

You can edit your first post and fix the typo there. Please also indent every line of code using four spaces. This will make the code much more readable. The button </> at the top of the edit text box helps you with this.

Thank you so much. @lutzhorn

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.