Created
January 31, 2016 05:02
-
-
Save hackintoshrao/69898cd223363f9985c6 to your computer and use it in GitHub Desktop.
demosntration of slice holding reference to the underlaying array
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 main() { | |
array := [4]int{1,2,3,4} | |
sliceFromArray := array[:3] | |
fmt.Printf("array = %v , slice = %v\n",array,sliceFromArray) | |
sliceFromArray[2] = 4 | |
fmt.Printf("array = %v , slice = %v\n",array,sliceFromArray) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment