Write smarter code with Sealed Classes and Lambdas in Kotlin
summary
Kotlin example builds a RecyclerView with a sealed StaggeredListItem hierarchy (BuyNow, Auction, Advertisement) attached to data classes so each case carries its own fields and benefits from smart casted properties without explicit casts. A generic BaseViewHolder<T: StaggeredListItem> plus an enum-backed getItemViewType keeps creation simple; lambdas replace bulky callback interfaces so clicks are passed as functions and composed at adapter construction. Compiler enforces exhaustive when branches and benchmarks show negligible lambda overhead.
AI-written summary · about
chapters (8)
- 0:00Introduction
- 1:36About the speaker
- 3:20Sealed classes basics
- 9:20Lambda expressions overview
- 13:55Combining sealed classes and lambdas
- 21:43Building a text store demo
- 26:03Handling new item types
- 29:14Q&A session
related talks
41mLeveraging Sealed Classes in Kotlin
53mKotlin: A Close Look at Innovative Language Features
35mSealed Classes, Unsealed Complexity
41mKotlin 102 – Beyond the basics
39mHow to Kotlin - from the lead Kotlin language designer
50mKotlin is as awesome as you've heard. Here's why.
43mFrom Effective Java to Effective Kotlin
41mKotlin 102 – Beyond the Basics
