Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- s := []int{2, 3, 5, 7, 11, 13}
- printSlice(s)
- // Slice the slice to give it zero length.
- printSlice(s[:0])
- // Extend its length
- printSlice(s[:4])
- // Drop its first two values.
- printSlice(s[2:])
- }
- func printSlice(s []int) {
- fmt.Printf("len=%d cap=%d %vn", len(s), cap(s), s)
- }
Add Comment
Please, Sign In to add comment