Created
June 25, 2018 11:47
-
-
Save ksakae1216/448ff228cfb40752a985d8aeea0623b8 to your computer and use it in GitHub Desktop.
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
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