Learning Kotlin: Using 'while loops', IntRanges, and the 'repeat' Function

preview_player
Показать описание
Another Learning Kotlin tutorial for beginners. Helping you learn Kotlin 1 small tutorial at a time.

In this Kotlin tutorial, you learn how to write 'while loops' and 'do while loops' . You'll see how to use the 'repeat' function to quickly iterate N number of times, and you'll learn how you can use IntRanges, the 'until' and 'downTo' infix functions, and the 'step' function to control how 'for loops' operate.

0:47 - Repeat function
3:06 - for loop using 'until'
4:00 - for loop using '..' range shorthand
5:39 - for loop using 'step' function to control how counter is incremented
6:40 - for loop using 'downTo' function to iterate backwards
8:35 - While loop
9:35 - Do-While loop

#AndroidDev #AndroidDeveloper #Kotlin

Thanks for watching!

Questions about iteration in Kotlin? Let me know in the comments 🙂

---

💡More Kotlin Resources:
📖Kotlin for Android Developers

🖥JetBrains certified online course: Kotlin for Android Developers

📚More Kotlin Books

📹Free Course From Udacity
---

🎒Check out books & gear that have helped me out
---

🙂 Follow Me Online

ℹsome links direct to affiliate sites
Рекомендации по теме
Комментарии
Автор

Were any of these new to you? I was recently reminded that using "until" is non-inclusive which makes it useful when looking up elements in a collection because you don't have to subtract 1 from the size of the collection.

goobar
Автор

For me the big disadvantage of "repeat" is that you can't "break" it or somehow finish before the all iterations happened

BelokonRoman
join shbcf.ru