kotlin foreach
var list = listOf<String>("1", "2", "3")
list.forEach {
println(it)
}
kotlin foreach
var list = listOf<String>("1", "2", "3")
list.forEach {
println(it)
}
kotlin loop
val school = arrayOf("shark", "salmon", "minnow")
for (element in school) {
print(element + " ")
}
-> shark salmon minnow
for ((index, element) in school.withIndex()) {
println("Item at $index is $element\n")
}
-> Item at 0 is shark
Item at 1 is salmon
Item at 2 is minnow
kotlin iterate array
val names = listOf("Anne", "Peter", "Jeff")
for (name in names) {
println(name)
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us