Skip to content

Instantly share code, notes, and snippets.

@ksakae1216
Created June 25, 2018 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksakae1216/448ff228cfb40752a985d8aeea0623b8 to your computer and use it in GitHub Desktop.
Save ksakae1216/448ff228cfb40752a985d8aeea0623b8 to your computer and use it in GitHub Desktop.
package funcpkg
import (
"fmt"
"strconv"
)
// ForFunc for文のサンプルです
func ForFunc() {
for i := 0; i < 3; i++ {
fmt.Println("i -> " + strconv.Itoa(i))
}
// whileのかわり
j := 3
for {
if j > 5 {
break
}
fmt.Println("j -> " + strconv.Itoa(j))
j++
}
// foreach
// "_"にindex値、"k"に配列の値が入る
kList := [...]string{"6", "7", "8"}
for _, k := range kList {
fmt.Println("k -> " + k)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment