
Here’s the link to the cheatsheet covering all 5 parts again. That’s it for part 4! The 5th and final Kotlin for Interviews article covers Frequently Used Code Snippets. forEachIndexed() is like forEach(), except you also have access to the element’s index inside the lambda, which you often need in interview problems.This is the iteration method I use most often in normal projects, but didn’t use as often in interviews because 1) forEach() will throw a ConcurrentModificationException if you try to modify the collection while iterating through it, and 2) a lot of interview problems require taking the index into account as well. forEach() performs the given action on each element in the collection.However, it also allows displaying the rendered document.

Its primary purpose is to provide a complete information about the rendered page suitable for further processing. The one you’ll encounter the most often is IntRange, but you can use LongRange and CharRange as well. CSSBox is an (X)HTML/CSS rendering engine written in pure Java. 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.
