In and out type variant of Kotlin
Published in
4 min readDec 28, 2017
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.