Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSS

golang for loop

import (
  "fmt"
)

func main() {

  numbs := []int{1, 2, 3, 4, 5}

  for numb := range numbs {
     fmt.Printf("using range: %d 
", numb)
  }
  
  fmt.Println("
")
    
  for i := 0; i < len(numbs); i++ {
    fmt.Printf("using for: %d 
", i)
  }
  
  fmt.Println("
")

  i := 0
  for i < len(numbs) {
   fmt.Printf("using for like while: %d 
", i)
   i++
 }  
 
}
 
PREVIOUS NEXT
Tagged: #golang #loop
ADD COMMENT
Topic
Name
5+6 =