Last active
October 18, 2018 06:09
-
-
Save pennya/1e1840da6c546c0013704a6e6bcad6f2 to your computer and use it in GitHub Desktop.
#Kotlin # for 다양한 사용방법
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
fun forTest(list: List<String>) { | |
for(item in list) { | |
println(item) | |
} | |
for(i in 0..list.size) { | |
println(list[i]) | |
} | |
for(i in list.indices) { | |
println(list[i]) | |
} | |
for((i, v) in list.withIndex()) { | |
println("index is $i, value is $v") | |
} | |
// 100까지 포함 | |
for(i in 1..100) {} | |
// 99까지 포함 | |
for(i in 1 until 100) {} | |
// 단위가 2 | |
for(i in 2..10 step 2) {} | |
// 1까지 숫자감소 | |
for(i in 10 downTo 1) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment