Created
November 11, 2019 16:29
-
-
Save cwansart/82f12480856bce37be04ace828761436 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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