Skip to content

Instantly share code, notes, and snippets.

@sugilog
Created January 1, 2015 00:35
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 sugilog/c8177da2f80c216ddc4d to your computer and use it in GitHub Desktop.
Save sugilog/c8177da2f80c216ddc4d to your computer and use it in GitHub Desktop.
スライス:スライシング
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