Stackademic

Stackademic is a learning hub for programmers, devs, coders, and engineers. Our goal is to…

Follow publication

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 and out keywords help manage subtypes in generics.
  • Star Projections: Dealing with unknown types in generics.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Published in Stackademic

Stackademic is a learning hub for programmers, devs, coders, and engineers. Our goal is to democratize free coding education for the world.

Written by Android Dev Nexus

Your friendly neighborhood developers working at PayPal, turning Android fundamentals into concepts you’ll actually understand.

Responses (3)

Write a response

Awesome post! Looking forward to the next article on Reified🤩🤩

I had so much trouble using it ..but this blog helped.
Thank you 😭

Wow. Great post on Generics.