![]() forEach() performs the given action on each element in the collection.The one you’ll encounter the most often is IntRange, but you can use LongRange and CharRange as well. The step, or distance between two values, has a default value of 1. Refresher on RangeĪ Range in Kotlin is a sequence of values defined by a start value, an end value, and a step. Many interview problems require some kind of iteration, be it manipulating an input array or using a map to store information, so I’ll go over different ways of iterating over some common data structures. You can find Part 1: Common Data Types here, Part 2: Collection Functions here and Part 3: Numbers and Math here and Part 5: Frequently Used Code Snippets here. also compiled a cheatsheet that covers all 5 parts of this series, which you can find here. This is Part 4 of Kotlin for Interviews, a series where I go over Kotlin functions and code snippets that came up often during my Android interview prep.
0 Comments
Leave a Reply. |