For Loops Kotlin

Code Bekasi
Sep 3, 2018 · 1 min read

Assalamualaikum warahmatullahi wabarakatuh.

kali ini saya akan membahasa tentang perulangan for pada kotlin , perulangan for untuk mengulang objek ketika dalam kondisi true.

contoh kita menggunakan kondisi withIndex() dan indices

val arrayNum = intArrayOf(1,2,3,4,5)

//withIndex()
for ((index, value) in arrayNum.withIndex()) {
print(“ini bilang $value adalah indeks ke-$index\n”)
}

//indices
for (index in arrayNum.indices) {
print(“ini bilangan ${arrayNumbers[index]} adalah indeks ke-$index\n”)
}

Sekian Pemabahasan dari saya tentang pengulan for pada kotlin.

wassalamualaikum warahmatullahi wabarakatuh.


Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade