Advertisement
cwchen

[Go] Modifying the elements in an array.

Sep 20th, 2017
936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.19 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     arr := [5]int{1, 2, 3, 4, 5}
  7.  
  8.     for i := 0; i < len(arr); i++ {
  9.         arr[i] = arr[i] * arr[i]
  10.     }
  11.  
  12.     for _, e := range arr {
  13.         fmt.Println(e)
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement