# An Illustrated Guide to Covariance and Contravariance in Kotlin

DevFeed: [An Illustrated Guide to Covariance and Contravariance in Kotlin](<https://devfeed.tech/articles/an-illustrated-guide-to-covariance-and-contravariance-in-kotlin-25035.md>)

Original publisher: [Read original article](<https://typealias.com/guides/illustrated-guide-covariance-contravariance/>)

Author: author@typealias.com (Dave Leeds)

Published: 2018-02-20T00:00:00Z

Content type: tutorial

Language: en

Sources: [Dave Leeds on Kotlin - typealias.com](<https://devfeed.tech/sources/dave-leeds-on-kotlin-typealias-com.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [generics](<https://devfeed.tech/topics/generics.md>), [Polymorphism](<https://devfeed.tech/topics/polymorphism.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [contravariance](<https://devfeed.tech/tags/contravariance.md>), [covariance](<https://devfeed.tech/tags/covariance.md>), [generic-variance](<https://devfeed.tech/tags/generic-variance.md>), [generics](<https://devfeed.tech/tags/generics.md>), [guide](<https://devfeed.tech/tags/guide.md>), [inheritance](<https://devfeed.tech/tags/inheritance.md>), [interface](<https://devfeed.tech/tags/interface.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>), [variance](<https://devfeed.tech/tags/variance.md>)

## AI overview

This illustrated Kotlin tutorial explains the foundational concepts behind generic variance. It focuses on subtyping, function arguments and results, and how covariance and contravariance appear in class and interface inheritance.

## Source excerpt

Generics can often seem confusing. How often have you started to solve a problem with generics, only to realize that they don't quite work like you thought they did? The good news is that there are some simple, foundational concepts that underpin generic variance. And once you understand those concepts, you won't have to memorize acronyms or resort to trial-and-error - you'll simply understand how and why they work! In this article, I'm going to cover these foundational concepts, and then demonstrate how they play out in Kotlin class and interface inheritance.