Guest User

Untitled

a guest
Dec 12th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6. s := []int{2, 3, 5, 7, 11, 13}
  7. printSlice(s)
  8.  
  9. // Slice the slice to give it zero length.
  10. printSlice(s[:0])
  11.  
  12. // Extend its length
  13. printSlice(s[:4])
  14.  
  15. // Drop its first two values.
  16. printSlice(s[2:])
  17. }
  18.  
  19. func printSlice(s []int) {
  20. fmt.Printf("len=%d cap=%d %vn", len(s), cap(s), s)
  21. }
Add Comment
Please, Sign In to add comment