Answers for "foreach golang"

Go
2

foreach golang

package main

import "fmt"

func main() {

	myList := []string{"dog", "cat", "hedgehog"}

	// for {key}, {value} := range {list}
	for _, animal := range myList {
		fmt.Println("My animal is:", animal)
	}
}
Posted by: Guest on February-17-2021
3

loop list golang

a := []string{"Foo", "Bar"}
for i, s := range a {
    fmt.Println(i, s)
}
Posted by: Guest on April-11-2020

Browse Popular Code Answers by Language