Created
January 1, 2015 00:35
-
-
Save sugilog/c8177da2f80c216ddc4d 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 main() { | |
sl1 := []int{ 10, 20, 30, 40, 50, 60, 70, 80, 90 } | |
sl2 := sl1[ 3:7 ] | |
sl3 := sl1[ 5: ] | |
sl4 := sl2[ :3 ] | |
fmt.Println( sl1 ) | |
fmt.Println( sl2 ) | |
fmt.Println( sl3 ) | |
fmt.Println( sl4 ) | |
sl2[ 1 ] = 51 | |
fmt.Println( sl1 ) | |
fmt.Println( sl2 ) | |
fmt.Println( sl3 ) | |
fmt.Println( sl4 ) | |
sl4[ 1 ] = 52 | |
fmt.Println( sl1 ) | |
fmt.Println( sl2 ) | |
fmt.Println( sl3 ) | |
fmt.Println( sl4 ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment