Member-only story
Kotlin Generics : Part 2 — Variance and Star Projections

Hey Kotlin enthusiasts! 👋 Welcome back to our Kotlin Series, where we explore all the awesomeness Kotlin has to offer. In the first part 🔄 of our Kotlin Generics, we covered the basics — what Generics are, how they enable type safety and flexibility, and why they’re a powerful tool for writing reusable code. We covered the concepts like generic classes, functions, and type constraints, as well as the difference between Generics and Any
. If you haven’t read it, below’s the link!
But there’s more to Generics. 💡 In this article, we’re going to level up by diving into advanced concepts of Kotlin Generics.
And hey, we’ve been holding a secret, all our articles are available for free. Here’s the link for this one. Enjoy (˵ ¬ᴗ¬˵)
Here’s what we’ll cover in Part 2:
🔍 What We’ll Explore:
- Variance: Understanding how the
in
andout
keywords help manage subtypes in generics. - Star Projections: Dealing with unknown types in generics.