“Ir iterando sobre una matriz en Golang” Código de respuesta

Golang Loop a través de la matriz

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

Ir iterando sobre una matriz en 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

Respuestas similares a “Ir iterando sobre una matriz en Golang”

Preguntas similares a “Ir iterando sobre una matriz en Golang”

Más respuestas relacionadas con “Ir iterando sobre una matriz en Golang” en Go

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código