Blog

Your dream job? Lets Git IT.
Interactive technical interview preparation platform designed for modern developers.

XGitHub

Platform

  • Categories

Resources

  • Blog
  • About the app
  • FAQ
  • Feedback

Legal

  • Privacy Policy
  • Terms of Service

© 2025 LetsGit.IT. All rights reserved.

LetsGit.IT/Categories/Kotlin
Kotlinmedium

Generics variance: what do `out` and `in` mean in Kotlin?

Tags
#kotlin#generics#variance#type-safety
Back to categoryPractice quiz

Answer

`out T` means the type only produces T (you can read T), so it’s covariant (e.g., `List<out Animal>` can hold `List<Dog>`). `in T` means it only consumes T (you can pass T in), so it’s contravariant (e.g., `Comparator<in Dog>`). It prevents unsafe reads/writes.

Related questions

Kotlin
coroutineScope vs supervisorScope: how do they handle failures?
#kotlin#coroutines#supervisor
Kotlin
StateFlow vs SharedFlow: what’s the difference?
#kotlin#stateflow#sharedflow
Kotlin
What does `typealias` do and what doesn’t it do?
#kotlin#typealias#types
Kotlin
Operator overloading: what does `operator` enable and what’s a caveat?
#kotlin#operator#overloading
Kotlin
Delegated properties (`by`): what problem do they solve?
#kotlin#delegation#properties
Kotlin
List vs MutableList in Kotlin: what’s the difference?
#kotlin#collections#immutability