“Golang Loop via le tableau” Réponses codées

Golang Loop via le tableau

arr := []int{1, 2, 3, 4, 5}
//using range 
for index, ele := range arr { // you can escape index by _ keyword
	fmt.Println(index, ele)
}
Glamorous camel

Liste des boucles Golang

a := []string{"Foo", "Bar"}
for i, s := range a {
    fmt.Println(i, s)
}
Bored Badger

aller en itérer sur un tableau à Golang

package main

import "fmt"

func main() {
    data := [...]string{"Ned", "Edd", "Jon", "Jeor", "Jorah"}
    for i := 0; i < len(data); i++ { //looping from 0 to the length of the array
        fmt.Printf("%d th element of data is %s\n", i, data[i])
    }
}
Binary Killer

Réponses similaires à “Golang Loop via le tableau”

Questions similaires à “Golang Loop via le tableau”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code