append() now returns the underlying array type. Method lookup was skipped for selector expression on arrays. Pointer expression was incorrectly parsed as a dereference instead of type expression.
20 lines
183 B
Go
20 lines
183 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
type IntArray []int
|
|
|
|
func (h *IntArray) Add(x int) {
|
|
*h = append(*h, x)
|
|
}
|
|
|
|
func main() {
|
|
a := IntArray{}
|
|
a.Add(4)
|
|
|
|
fmt.Println(a)
|
|
}
|
|
|
|
// Output:
|
|
// [4]
|