For Loop

Run Settings
LanguageKotlin
Language Version
Run Command
fun main(args : Array<String>){ // loopStep() //withIndex() //withForEach() eachIndex() } fun loopRange(){ val ranges = 1..5 //val ranges = 1.rangeTo(5) for(i in ranges){ println("value is $i") } } fun loopStep(){ val ranges = 1.rangeTo(10) step 3 for(i in ranges){ println("value is $i") } } //loop for with index fun withIndex(){ val ranges = 1.rangeTo(10) step 3 for((index, value) in ranges.withIndex()){ println("value $value with index $index") } } //with for each fun withForEach(){ val ranges = 1.rangeTo(10) step 3 ranges.forEach{ value -> println("value is $value") } } //with each and index fun eachIndex(){ val ranges = 1.rangeTo(10) step 3 ranges.forEachIndexed{ index, value -> println("value $value with index $index") } ranges.forEachIndexed{ index, _ -> println("index $index") } }
Editor Settings
Theme
Key bindings
Full width
Lines