You can print the array elements using the loop same as the Java enhanced loop, but you need to change keyword from :
to in
.
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);
}