Created
November 5, 2019 21:22
-
-
Save kjk/f807e821184ffe8409d40f55de373044 to your computer and use it in GitHub Desktop.
for loop over a slice with range
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// :collection Essential Go | |
package main | |
import "fmt" | |
func main() { | |
// :show start | |
a := []int{1, 3, 5} | |
for idx, value := range a { | |
fmt.Printf("idx: %d, value: %d\n", idx, value) | |
} | |
// :show end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment