Skip to content

Instantly share code, notes, and snippets.

@sirpengi
Created February 4, 2013 06:59
Show Gist options
  • Save sirpengi/4705352 to your computer and use it in GitHub Desktop.
Save sirpengi/4705352 to your computer and use it in GitHub Desktop.
go question
package main
func modify (myarr *[]int) {
myarr = append(*myarr, 4)
}
func main() {
arr := []int{}
arr = append(arr, 1)
arr = append(arr, 2)
arr = append(arr, 3)
println(len(arr))
modify(&arr)
println(len(arr))
s := 0
for _, v := range arr {
s = s + v
}
println("Result:", s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment