-
Book Overview & Buying
-
Table Of Contents
Android Programming for Beginners - Fourth Edition
By :
As the title suggests, in this chapter, we will learn about ranges (a concept) and when, a keyword. A range in Kotlin is exactly what it sounds like; a range of values with a starting value and an ending value, but much more interesting, and what we will explore in this chapter is what we can do with ranges and the associated keywords.
A when-based expression in Kotlin is a neat replacement for if-else blocks, allowing you to match a value against multiple conditions in a concise, readable way. The when keyword is yet another part of Kotlin's expressiveness, enabling us to write clearer, less error-prone code, often in less time. Furthermore, as with ranges, there are a bunch of associated keywords we can use in conjunction with when that give us more refined control over the execution of our apps.
In addition, we will learn more Jetpack layout tricks by introducing LazyColumn, along with ranges and when in 2 demo apps.
In this chapter, we will: