Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
101
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.  
  7. a := make([]byte, 100)
  8. b := a
  9.  
  10. a[10] = 'y'
  11. b[10] = 'x'
  12.  
  13. fmt.Println(a[10])
  14. fmt.Println(b[10])
  15.  
  16. c := [3]byte{1, 2, 3}
  17. d := c
  18.  
  19. c[2] = 'x'
  20. d[2] = 'y'
  21. fmt.Println(c[2])
  22. fmt.Println(d[2])
  23.  
  24. g := c[:]
  25. h := g
  26.  
  27. g[2] = 'x'
  28. h[2] = 'y'
  29. fmt.Println(g[2])
  30. fmt.Println(h[2])
  31.  
  32. }
  33.  
  34. /*
  35. Output
  36.  
  37. 120
  38. 120
  39. 120
  40. 121
  41. 121
  42. 121
  43.  
  44. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement