In and out type variant of Kotlin

If you ever defined generic in Kotlin, you’ll notice many a times, it would propose to use the in or out keyword to define the generic. It puzzles me at a start on when which is used, and for what.

Formally, this is a way to define contravariance and covariant. It took me a while to learn about it. I’ll dive in here to explain what how I understand and memorize their different.




Sharing iOS, Android and relevant Mobile App Development Technology and Learning

Recommended from Medium

CS371p Spring 2021: Erica Martinez

The name of the blog post I made is Java Program. What is Java? How many Java sites are there?

MakerEd / Beacons of tomorrow

Blog — Linux LIBRARIES

10 Things to do when conducting your Exploratory Data Analysis (EDA)

Events for Cloud Run for Anthos >= Knative Eventing on Kubernetes

Measuring IP Connectivity with RIPE Atlas

Let’s Abandon Customers and Users

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Sharing Software Development Experience, focus on Mobile.

More from Medium

Kotlin Coroutines Flow in a nutshell

Empowered Lifecycle-Aware ViewModel For Android

How Kotlin By Variable Delegate Helps Me Avoid Anti-Pattern

Enhancing Android App Architecture with Domain Layer