Iterate Array
suggest changeYou can print the array elements with a loop like Java’s enhanced for, but the keyword is in rather than :.
val asc = Array(5, { i -> (i * i).toString() })
for(s : String in asc){
println(s);
}
You can also change data type in for loop.
val asc = Array(5, { i -> (i * i).toString() })
for(s in asc){
println(s);
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents