Skip to content

Instantly share code, notes, and snippets.

@cwansart
Created November 11, 2019 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwansart/82f12480856bce37be04ace828761436 to your computer and use it in GitHub Desktop.
Save cwansart/82f12480856bce37be04ace828761436 to your computer and use it in GitHub Desktop.
package main
import "fmt"
func change(a []int) {
for i := 0; i < len(a); i++ {
a[i] = 42
}
}
func main() {
numbers := []int{1,2,3}
fmt.Println(numbers) // prints [1 2 3]
change(numbers)
fmt.Println(numbers) // prints [42 42 42]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment