Created
July 3, 2018 14:29
-
-
Save jjuliano/931a74a7d0cf331d9c5b391090416fa9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 main() { | |
slicedArray1 := make([]string, 4) | |
var slicedArray2 []string | |
slicedArray3 := []string{} | |
slicedArray4 := []string{"foo", "bar"} | |
slicedArray1[0] = "foo" | |
slicedArray2 = slicedArray1 | |
slicedArray2[1] = "bar" | |
slicedArray3 = slicedArray2 | |
slicedArray3[2] = "baz" | |
slicedArray4 = slicedArray3 | |
slicedArray4[3] = "quux" | |
fmt.Println(slicedArray1) // [foo bar baz quux] | |
fmt.Println(slicedArray2) // [foo bar baz quux] | |
fmt.Println(slicedArray3) // [foo bar baz quux] | |
fmt.Println(slicedArray4) // [foo bar baz quux] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment