Advertisement
cwchen

[Go] Iterating through an array.

Sep 20th, 2017
928
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.     langs := [4]string{
  7.         "Go",
  8.         "Python",
  9.         "Ruby",
  10.         "PHP",
  11.     }
  12.  
  13.     for i, e := range langs {
  14.         fmt.Println(fmt.Sprintf("%d: %s", i+1, e))
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement