Kotlin Generics In Depth
summary
Covers how Kotlin enforces in/out variance (why mutable List<String> ≠ MutableList<Any>), demonstrates use-site variance and star projection with concrete examples, shows how upper bounds let a star projection carry duck-specific methods, and explains reified type parameters via inline functions so emptyList<Duck>() can be distinguished at runtime. Includes practical notes: unsafeVariance in immutable collections, extension functions for constrained generics, and Jackson Kotlin module deserialization use cases.
AI-written summary · about
chapters (8)
- 0:00Introduction
- 1:08What are generics
- 3:36Understanding variance
- 10:17Variance annotations
- 14:12Type projection explained
- 19:26Type constraints and bounds
- 24:15Reification in Kotlin
- 28:29Q&A and resources
related talks
46mKotlin 102 - Beyond the basics
39mKotlin variance modifiers and Covariant Object Nothing pattern.
42mAdvanced Kotlin
43mThe Road to Kotlintown
48mType Variance in Java and Kotlin
41mKotlin 102 – Beyond the Basics
38mKotlin variance modifiers and Covariant Object Nothing pattern
41mKotlin 102 – Beyond the basics
