Advertisement
cwchen

[Go] Extending a slice (from 5 to 8).

Sep 20th, 2017
930
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.24 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "log"
  5. )
  6.  
  7. func main() {
  8.     slice := []int{1, 2, 3, 4, 5}
  9.  
  10.     if !(len(slice) == 5) {
  11.         log.Fatal("Wrong length")
  12.     }
  13.  
  14.     slice = append(slice, 6, 7, 8)
  15.  
  16.     if !(len(slice) == 8) {
  17.         log.Fatal("Wrong length")
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement