Kotlin TutorialLesson 17Free preview
Kotlin For Loop
This lesson is part of Kotlin · All levels
Summary
This lesson reviews the iteration of 'for' in Kotlin which adopts the concept of the 'for in' iterator. This repetition is very flexible for tracking array elements, data collection (List, Set, Map), and the range of numbers. Beginner developers will learn how to read elements and their indexes using withIndex().
Key points
- The repetition of 'for (item in collection) ' iterates each element that provides the iterator
- Working smoothly with ranges and data collection
- The '.indices' function produces a valid index range of an array
- The '.withIndex() ' function allows destructing index and value pairs simultaneously
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.