

assign class objects by appending ::class.java to the parameter name.Advantages of using reified types parameters:.Work with those functions that are declared to be inline.Work only with functions (or extension properties that have a get() function).In the case of reified type parameters in Kotlin we can compare types and get Class objects.The type information is said to be erased.Enforcing type constraints only at compile time and discarding the element type information at runtime.At runtime, the instances of generic types do not hold any information about their actual type arguments. The type safety checks that Kotlin performs for generic declaration usages are only done at compile time.Java has limits on what types are considered reifiable – meaning they’re “completely available at run time” (see the Java SE specs on reifiable types).Hosted with ❤ by GitHub 8️⃣Type erasure and reified type parameters So then, we have three ways that we can accept any kind of a generic:.It produces the same effective interface as the other two approaches: Instead of using C or C, you can just use C.The safe way here is to define such a projection of the generic type, that every concrete instantiation of that generic type would be a subtype of that projection.They come in handy when we know nothing about the type argument, but need to use them in a safe way.A type projection is a type that has been limited in certain ways in order to gain variance characteristics using use-site variance.To remember: Lambdas are contra-variant in their argument types and covariant in their return type.Type is both a producer and consumer of T.T appears in both “in position” and “out position”.
