Programming in Kotlin: Fundamentals

Aug 9 2022 Kotlin 1.6, Android 12, IntelliJ IDEA CE 2022.1.3

Part 2: Manage Control Flow

13. Work with For Loops

Lesson Complete

Play Next Lesson
Next
Save for later
About this episode
See versions
See forum comments
Cinema mode Mark as Complete Download course materials
Previous episode: 12. Challenge: Use While Loops Next episode: 14. Challenge: Use For Loops

This video was last updated on Aug 9 2022

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.

Previously you learned which loops exist in Kotlin.

val rangeFromZeroToTen = 0..10 
println(rangeFromZeroToTen)
val exclusiveRange = 0 until 10
println(exclusiveRange)
for (index in rangeFromZeroToTen) {
  print(index)
}

println("")
for (index in rangeFromZeroToTen step 2) {
  print(index)
}

println("")
for (index in 10..0) {
  print(index)
}

println("")
for (index in 10 downTo 0) {
  print(index)
}

println("")