# generic

Published articles for generic.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Kotlin type aliases versus functional interfaces for debuggable, distinct handler types

DevFeed: [Kotlin type aliases versus functional interfaces for debuggable, distinct handler types](<https://devfeed.tech/articles/the-case-of-the-missing-handler-27350.md>)

Original publisher: [Read original article](<https://blog.mmckenna.me/the-case-of-the-missing-handler>)

Author: Matt McKenna

Published: 2025-08-28T04:00:22Z

Content type: tutorial

Language: en

Sources: [Matt McKenna](<https://devfeed.tech/sources/matt-mckenna.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [interfaces](<https://devfeed.tech/topics/interfaces.md>), [debugging](<https://devfeed.tech/topics/debugging.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [code](<https://devfeed.tech/tags/code.md>), [debugger](<https://devfeed.tech/tags/debugger.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [function](<https://devfeed.tech/tags/function.md>), [generic](<https://devfeed.tech/tags/generic.md>), [interface](<https://devfeed.tech/tags/interface.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>)

### AI overview

This Kotlin article explains that a type alias for a function type does not create a distinct type, so its name can disappear from debugging and stack traces. It recommends functional interfaces when type identity, discoverability, distinct callbacks, and simple testing fakes are important.

### Source excerpt

Our story begins with a clean line of Kotlin: typealias Handler = (result: Result) -> Unit It looks innocent. Give a function type a name and tidy up the signatures, great! Then a bug hits. The Handler is gone in the debugger and in stack traces onl...

## Interfaces 101 : Heap Escape Ep. 2

DevFeed: [Interfaces 101 : Heap Escape Ep. 2](<https://devfeed.tech/articles/interfaces-101-heap-escape-ep-2-22215.md>)

Original publisher: [Read original article](<https://www.ardanlabs.com/blog/2023/02/interfaces-101-heap-escape.html>)

Published: 2023-02-08T00:00:00Z

Content type: tutorial

Language: en

Sources: [William Kennedy](<https://devfeed.tech/sources/william-kennedy.md>)

Topics: [interfaces](<https://devfeed.tech/topics/interfaces.md>), [Go Language](<https://devfeed.tech/topics/go-language.md>), [Benchmark](<https://devfeed.tech/topics/benchmark.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [Code](<https://devfeed.tech/topics/code.md>), [Logging](<https://devfeed.tech/topics/logging.md>)

Tags: [benchmark](<https://devfeed.tech/tags/benchmark.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [escape-heap](<https://devfeed.tech/tags/escape-heap.md>), [function](<https://devfeed.tech/tags/function.md>), [generic](<https://devfeed.tech/tags/generic.md>), [go](<https://devfeed.tech/tags/go.md>), [golang](<https://devfeed.tech/tags/golang.md>), [inlining](<https://devfeed.tech/tags/inlining.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [log-variables](<https://devfeed.tech/tags/log-variables.md>), [logging](<https://devfeed.tech/tags/logging.md>), [performance](<https://devfeed.tech/tags/performance.md>)

### AI overview

This video examines the performance implications of using interfaces in Go, including how interface use can cause variables to escape to the heap. It demonstrates benchmarking code, examining compiler optimizations, identifying heap allocations, and preventing function inlining.

### Source excerpt

Introduction In episode 1, Miki had two functions that performed the similar operation, but returned different types. To refactor this, Miki rewrote both functions as a generic function that allowed him to specify the type to be returned during invocation. In some cases, the compiler may not recognise a type, thus, Miki gives a few pointers on manually telling a generic function which type to use. After demonstrating how to return different types with a generic function, Miki limited the types his generic function would accept with an interface.

## Examples of Classes in Kotlin

DevFeed: [Examples of Classes in Kotlin](<https://devfeed.tech/articles/examples-of-classes-in-kotlin-25009.md>)

Original publisher: [Read original article](<https://typealias.com/concepts/class/>)

Author: author@typealias.com (Dave Leeds)

Published: 2020-08-31T00: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>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [classes](<https://devfeed.tech/tags/classes.md>), [code](<https://devfeed.tech/tags/code.md>), [concepts](<https://devfeed.tech/tags/concepts.md>), [constructor](<https://devfeed.tech/tags/constructor.md>), [examples](<https://devfeed.tech/tags/examples.md>), [function](<https://devfeed.tech/tags/function.md>), [generic](<https://devfeed.tech/tags/generic.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>), [property](<https://devfeed.tech/tags/property.md>), [reference](<https://devfeed.tech/tags/reference.md>), [visibility-modifier](<https://devfeed.tech/tags/visibility-modifier.md>)

### AI overview

A quick reference to creating classes in Kotlin, including a simple class with no properties or functions. It explains that classes combine variables and functions into a single unit.

### Source excerpt

One core concept in Kotlin is a class, which allows you to combine variables and functions into a single unit. This article is a quick reference that shows how to create classes in Kotlin. There's also a full article called Introduction to Classes and Objects, which is a gentle introduction to these concepts, so if you're new to the language, you might want to start there! A Simple Class For a class that has no properties or functions, you can create a class in Kotlin with very little code:

## What's coming in TypeScript 4?

DevFeed: [What's coming in TypeScript 4?](<https://devfeed.tech/articles/what-s-coming-in-typescript-4-19103.md>)

Original publisher: [Read original article](<https://httptoolkit.com/blog/whats-coming-in-typescript-4/>)

Author: HTTP Toolkit; Tim Perry

Published: 2020-06-22T16:00:00Z

Content type: tutorial

Language: en

Sources: [HTTP Toolkit](<https://devfeed.tech/sources/http-toolkit.md>)

Topics: [TypeScript](<https://devfeed.tech/topics/typescript.md>), [Code](<https://devfeed.tech/topics/code.md>), [Development](<https://devfeed.tech/topics/development.md>)

Tags: [arrays](<https://devfeed.tech/tags/arrays.md>), [code](<https://devfeed.tech/tags/code.md>), [development](<https://devfeed.tech/tags/development.md>), [function](<https://devfeed.tech/tags/function.md>), [generic](<https://devfeed.tech/tags/generic.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [patterns](<https://devfeed.tech/tags/patterns.md>), [typescript](<https://devfeed.tech/tags/typescript.md>)

### AI overview

An overview of planned TypeScript 4 additions, focusing on variadic tuple types. The article explains how these types can preserve more precise information when typing functions that accept and combine tuple arguments, including concatenation and flexible rest parameters.

### Source excerpt

TypeScript 4 is coming up fast: a first beta release is planned for this week (June 25th), with the final release aiming for mid-August. It's important to note that TypeScript does not follow semver, so 4.0 is not as big a deal as it sounds! There can be (and often are) breaking changes between any minor TypeScript versions, and major version bumps like this happen primarily for marketing reasons, not technical ones. This bump to 4.0 doesn't suggest that everything is going to break, and this won't be a huge world-changing release, but it does bring some nice additions, particularly on the typing side. For projects like HTTP Toolkit (written entirely in TypeScript) that means faster development & fewer bugs! Let's dive into the details: Variadic tuple types Also known as 'variadic kinds', this is a complex but substantial new feature for TypeScript's type system. ~~It's not 100% confirmed yet (the PR remains unmerged!), but it's explicitly in the 4.0 roadmap, and Anders Hejlsberg himself has called it out as planned for the coming release.~~ Update: PR now merged, looks like this is happening! Explaining this is complicated if you don't have an strong existing grasp of type theory, but it's easy to demo. Let's try to type a concat function with tuple arguments: function concat( nums: number[], strs: string[] ): (string | number)[] { return [...nums, ...strs]; } let vals = concat([1, 2], ["hi"]); let val = vals[1]; // infers string | number, but we *know* it's a number (2) // TS does support accurate types for these values though: let typedVals = concat([1, 2], ["hi"]) as [number, number, string]; let typedVal = typedVals[1] // => infers number, correctly This is valid TypeScript code today, but it's suboptimal. Here, concat works OK, but we're losing information in the types and we have to manually fix that later if we want to get accurate values elsewhere. Right now it's impossible to fully type such a function to avoid this. With variadic types though, we can: fun

## Star-Projections and How They Work

DevFeed: [Star-Projections and How They Work](<https://devfeed.tech/articles/star-projections-and-how-they-work-25043.md>)

Original publisher: [Read original article](<https://typealias.com/guides/star-projections-and-how-they-work/>)

Author: author@typealias.com (Dave Leeds)

Published: 2018-04-05T00: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: [generics](<https://devfeed.tech/topics/generics.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [class](<https://devfeed.tech/tags/class.md>), [function](<https://devfeed.tech/tags/function.md>), [generic](<https://devfeed.tech/tags/generic.md>), [generic-variance](<https://devfeed.tech/tags/generic-variance.md>), [generics](<https://devfeed.tech/tags/generics.md>), [guide](<https://devfeed.tech/tags/guide.md>), [interface](<https://devfeed.tech/tags/interface.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [parameter](<https://devfeed.tech/tags/parameter.md>), [programming](<https://devfeed.tech/tags/programming.md>), [star-projection](<https://devfeed.tech/tags/star-projection.md>), [type-projection](<https://devfeed.tech/tags/type-projection.md>), [types](<https://devfeed.tech/tags/types.md>), [use-site-variance](<https://devfeed.tech/tags/use-site-variance.md>), [variance](<https://devfeed.tech/tags/variance.md>)

### AI overview

This tutorial explains how Kotlin star-projections work when a function must accept any kind of a generic. It applies subtyping rules for accepted and returned types to compare star-projections with other type-safe solutions.

### Source excerpt

Have you ever wondered how star-projections work? Or why they change your function parameter and return types? Or why it seems like sometimes you can actually get by without them? In the first article in this series, An Illustrated Guide to Covariance and Contravariance in Kotlin, we uncovered two simple, easy-to-understand rules that illuminate variance, and saw how they applied to regular class and interface inheritance in Kotlin. In the second article, The Ins and Outs of Generic Variance in Kotlin, we saw how those same two rules played out for generics, discovering what type projections are and how they work.

## Out-Projection

DevFeed: [Out-Projection](<https://devfeed.tech/articles/out-projection-25020.md>)

Original publisher: [Read original article](<https://typealias.com/concepts/out-projection/>)

Author: author@typealias.com (Dave Leeds)

Published: 2018-02-05T00: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>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [covariance](<https://devfeed.tech/tags/covariance.md>), [generic](<https://devfeed.tech/tags/generic.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>), [type-projection](<https://devfeed.tech/tags/type-projection.md>), [use-site-variance](<https://devfeed.tech/tags/use-site-variance.md>), [variance](<https://devfeed.tech/tags/variance.md>)

### AI overview

This tutorial explains Kotlin out-projections, showing how they provide covariance at a use site while preventing operations that accept the projected type parameter. It covers the type-safety limitation and when out-projections are useful compared with declaration-site variance.

### Source excerpt

An out-projection is a kind of type projection that makes a generic covariant, but also causes any functions that accept the type parameter to be unusable in that context. You can think of it this way - In regular life, when some three-dimensional thing casts a shadow, that shadow is a two-dimensional projection of the original object - it's an incomplete representation of it. In the same way, an out-projection is a limited view of the original class.

## Declaration-Site Variance

DevFeed: [Declaration-Site Variance](<https://devfeed.tech/articles/declaration-site-variance-25012.md>)

Original publisher: [Read original article](<https://typealias.com/concepts/declaration-site-variance/>)

Author: author@typealias.com (Dave Leeds)

Published: 2018-01-17T00: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>)

Tags: [class](<https://devfeed.tech/tags/class.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [covariance](<https://devfeed.tech/tags/covariance.md>), [declaration-site-variance](<https://devfeed.tech/tags/declaration-site-variance.md>), [function](<https://devfeed.tech/tags/function.md>), [generic](<https://devfeed.tech/tags/generic.md>), [interface](<https://devfeed.tech/tags/interface.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>), [property](<https://devfeed.tech/tags/property.md>), [type-parameter](<https://devfeed.tech/tags/type-parameter.md>), [variance](<https://devfeed.tech/tags/variance.md>)

### AI overview

This tutorial explains Kotlin declaration-site variance, including the in and out annotations, the restrictions they impose on type parameters, and the resulting subtyping relationships such as covariance.

### Source excerpt

Declaration-Site Variance is variance that is specified at the point where the generic is defined - for example, in the definition of the class, interface, function, or extension property. To use declaration-site variance, you just have to modify a type parameter with either the in or out variance annotation. By doing this, you limit where you're allowed to use the type parameter, but you also introduce subtyping for your generic, so that, for example, a Box<Dog> can be a subtype of Box<Animal>, whereas otherwise this wouldn't be possible.

## Type Argument

DevFeed: [Type Argument](<https://devfeed.tech/articles/type-argument-25024.md>)

Original publisher: [Read original article](<https://typealias.com/concepts/type-argument/>)

Author: author@typealias.com (Dave Leeds)

Published: 2018-01-10T02:43:41Z

Content type: tutorial

Language: en

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

Topics: [generics](<https://devfeed.tech/topics/generics.md>), [Code](<https://devfeed.tech/topics/code.md>), [context](<https://devfeed.tech/topics/context.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>)

Tags: [compiler](<https://devfeed.tech/tags/compiler.md>), [context](<https://devfeed.tech/tags/context.md>), [generic](<https://devfeed.tech/tags/generic.md>), [generics](<https://devfeed.tech/tags/generics.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [parameter](<https://devfeed.tech/tags/parameter.md>), [programming](<https://devfeed.tech/tags/programming.md>), [type-argument](<https://devfeed.tech/tags/type-argument.md>), [type-parameter](<https://devfeed.tech/tags/type-parameter.md>), [type-parameters](<https://devfeed.tech/tags/type-parameters.md>), [type-projection](<https://devfeed.tech/tags/type-projection.md>), [types](<https://devfeed.tech/tags/types.md>), [variance](<https://devfeed.tech/tags/variance.md>)

### AI overview

This article explains type arguments in generics, including how they are specified in type declarations and function calls, inferred by the compiler, and used with variance annotations for type projection. It also distinguishes type arguments from type parameters.

### Source excerpt

A type argument is a specific type, specified by the calling code, that a generic will use in place of a type parameter. If your generic were a light fixture, then the light bulb that's screwed into that light fixture is the type argument. Just as different kinds of light bulbs can be used in a light fixture's socket, different call sites can each specify a different type argument to use in instances of a generic.

## Type Parameter

DevFeed: [Type Parameter](<https://devfeed.tech/articles/type-parameter-25027.md>)

Original publisher: [Read original article](<https://typealias.com/concepts/type-parameter/>)

Author: author@typealias.com (Dave Leeds)

Published: 2018-01-04T03:23:40Z

Content type: tutorial

Language: en

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

Topics: [generics](<https://devfeed.tech/topics/generics.md>), [Code](<https://devfeed.tech/topics/code.md>), [interfaces](<https://devfeed.tech/topics/interfaces.md>)

Tags: [class](<https://devfeed.tech/tags/class.md>), [classes](<https://devfeed.tech/tags/classes.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [function](<https://devfeed.tech/tags/function.md>), [generic](<https://devfeed.tech/tags/generic.md>), [generics](<https://devfeed.tech/tags/generics.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>), [reification](<https://devfeed.tech/tags/reification.md>), [type-parameter](<https://devfeed.tech/tags/type-parameter.md>), [variance](<https://devfeed.tech/tags/variance.md>)

### AI overview

This tutorial explains type parameters in generics: how they are declared and used, naming conventions, constraints that limit allowable types, variance in generic subtyping, and reified type parameters.

### Source excerpt

A type parameter is a placeholder for an actual type, which gets specified by the code that's using the generic. If you imagine your generic as a light fixture, the type parameter would be the socket where the light bulb goes. Just as you can choose from a variety of different light bulbs to put into that socket, the calling code can choose from a variety of different types to pass to a generic.

## Type Projection

DevFeed: [Type Projection](<https://devfeed.tech/articles/type-projection-25028.md>)

Original publisher: [Read original article](<https://typealias.com/concepts/type-projection/>)

Author: author@typealias.com (Dave Leeds)

Published: 2017-12-27T18:18:01Z

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>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [compiler](<https://devfeed.tech/tags/compiler.md>), [declaration-site-variance](<https://devfeed.tech/tags/declaration-site-variance.md>), [generic](<https://devfeed.tech/tags/generic.md>), [generic-variance](<https://devfeed.tech/tags/generic-variance.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [object](<https://devfeed.tech/tags/object.md>), [operations](<https://devfeed.tech/tags/operations.md>), [programming](<https://devfeed.tech/tags/programming.md>), [type-projection](<https://devfeed.tech/tags/type-projection.md>), [use-site-variance](<https://devfeed.tech/tags/use-site-variance.md>), [variance](<https://devfeed.tech/tags/variance.md>)

### AI overview

This tutorial explains Kotlin type projection as a restricted view of an existing type that enables variance and subtyping in specific contexts. It describes how use-site variance produces projections and how projections can restrict operations such as setters.

### Source excerpt

A type projection is a type that has been limited in certain ways in order to gain variance characteristics. Imagine a three-dimensional object that you shine a flashlight onto. Behind that object on the wall is a two-dimensional projection of that object - a shadow. That projection has the same basic shape as the object, but only from one perspective. Type projection is kind of like that - we take an existing object and reduce it to just the attributes or operations that we need at that place in the code.

## Variance Annotation

DevFeed: [Variance Annotation](<https://devfeed.tech/articles/variance-annotation-25029.md>)

Original publisher: [Read original article](<https://typealias.com/concepts/variance-annotation/>)

Author: author@typealias.com (Dave Leeds)

Published: 2017-12-04T02:49:24Z

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>)

Tags: [class](<https://devfeed.tech/tags/class.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [declaration-site-variance](<https://devfeed.tech/tags/declaration-site-variance.md>), [function](<https://devfeed.tech/tags/function.md>), [generic](<https://devfeed.tech/tags/generic.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [parameter](<https://devfeed.tech/tags/parameter.md>), [programming](<https://devfeed.tech/tags/programming.md>), [subtype](<https://devfeed.tech/tags/subtype.md>), [type-argument](<https://devfeed.tech/tags/type-argument.md>), [types](<https://devfeed.tech/tags/types.md>), [use-site-variance](<https://devfeed.tech/tags/use-site-variance.md>), [variance](<https://devfeed.tech/tags/variance.md>)

### AI overview

This tutorial explains variance annotations in Kotlin generics. It covers the out modifier for covariance, the in modifier for contravariance, and the invariant behavior when no variance annotation is declared.

### Source excerpt

A variance annotation is a modifier applied to a type parameter or type argument of a generic, in order to declare its variance. Kotlin defines two variance annotations in its grammar: out and in. out The out modifier is used to declare a type parameter as being covariant. For example: class Box<out T>(private val item: T) { fun getItem(): T = item } With the out variance annotation declared on the type parameter T in this class, subtyping rules can now be applied to Boxes of different types.

## Invariance

DevFeed: [Invariance](<https://devfeed.tech/articles/invariance-25018.md>)

Original publisher: [Read original article](<https://typealias.com/concepts/invariance/>)

Author: author@typealias.com (Dave Leeds)

Published: 2017-11-28T03:03:36Z

Content type: tutorial

Language: en

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

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

Tags: [classes](<https://devfeed.tech/tags/classes.md>), [function](<https://devfeed.tech/tags/function.md>), [generic](<https://devfeed.tech/tags/generic.md>), [generics](<https://devfeed.tech/tags/generics.md>), [inheritance](<https://devfeed.tech/tags/inheritance.md>), [invariance](<https://devfeed.tech/tags/invariance.md>), [java](<https://devfeed.tech/tags/java.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>), [properties](<https://devfeed.tech/tags/properties.md>), [subtype](<https://devfeed.tech/tags/subtype.md>), [type-parameter](<https://devfeed.tech/tags/type-parameter.md>), [variance](<https://devfeed.tech/tags/variance.md>)

### AI overview

This tutorial explains invariance in generic subtyping. It shows that generic types can remain unrelated even when their component types have a subtype relationship, and discusses default invariance in Kotlin and Java, multiple type parameters, and variance in inherited properties and function types.

### Source excerpt

When dealing with simple classes, subtyping is straightforward. But once we start talking about generics, subtyping rules become more complicated, and we describe the subtyping rules in terms of variance. What is Invariance? Invariance describes a relationship between two sets of types where the complex types do not subtype at all, despite any subtyping that might exist for the component types. Does that sound confusing?1 Thankfully, it's way more easily demonstrated than defined, so let's look at an example.

## Contravariance

DevFeed: [Contravariance](<https://devfeed.tech/articles/contravariance-25010.md>)

Original publisher: [Read original article](<https://typealias.com/concepts/contravariance/>)

Author: author@typealias.com (Dave Leeds)

Published: 2017-11-17T01:58:28Z

Content type: tutorial

Language: en

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

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

Tags: [classes](<https://devfeed.tech/tags/classes.md>), [contravariance](<https://devfeed.tech/tags/contravariance.md>), [generic](<https://devfeed.tech/tags/generic.md>), [generics](<https://devfeed.tech/tags/generics.md>), [inheritance](<https://devfeed.tech/tags/inheritance.md>), [java](<https://devfeed.tech/tags/java.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>), [type-parameter](<https://devfeed.tech/tags/type-parameter.md>), [types](<https://devfeed.tech/tags/types.md>), [variance](<https://devfeed.tech/tags/variance.md>)

### AI overview

This tutorial explains contravariance as a type relationship in which subtyping proceeds in opposite directions. It uses inheritance and generic classes to show how contravariant type parameters affect subtype relationships, usage, and the ability to return values of the parameter type.

### Source excerpt

Most of the time, subtyping is intuitive. Object-oriented programmers are used to the concept of inheritance, where one class specializes another, and we're familiar with the idea of passing, say, a Dog object where a function expects an Animal. Once you start working with generics, though, there are some fascinating twists that flip our typical understanding of subtyping on its head. What is Contravariance? Contravariance describes a relationship between two sets of types where they subtype in opposite directions.

## Covariance

DevFeed: [Covariance](<https://devfeed.tech/articles/covariance-25011.md>)

Original publisher: [Read original article](<https://typealias.com/concepts/covariance/>)

Author: author@typealias.com (Dave Leeds)

Published: 2017-11-14T00: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: [generics](<https://devfeed.tech/topics/generics.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Polymorphism](<https://devfeed.tech/topics/polymorphism.md>)

Tags: [classes](<https://devfeed.tech/tags/classes.md>), [contravariance](<https://devfeed.tech/tags/contravariance.md>), [covariance](<https://devfeed.tech/tags/covariance.md>), [generic](<https://devfeed.tech/tags/generic.md>), [generics](<https://devfeed.tech/tags/generics.md>), [inheritance](<https://devfeed.tech/tags/inheritance.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>), [subtype](<https://devfeed.tech/tags/subtype.md>), [superclass](<https://devfeed.tech/tags/superclass.md>), [variance](<https://devfeed.tech/tags/variance.md>)

### AI overview

This tutorial explains covariance in type systems, focusing on how subtype relationships behave with generic types. It uses Kotlin examples to distinguish covariant read-only types from invariant mutable types, shows how to declare covariance with the out annotation, and discusses related constraints involving function arguments, properties, and inheritance.

### Source excerpt

On the surface, subtypes seem straightforward. Most programmers who write object-oriented code are familiar with the concept of inheritance, and how you can pass off a subclass as if it were its superclass. But subtyping rules aren't always as intuitive when you start working with generics. What is Covariance? Covariance describes a relationship between two sets of types where they both subtype in the same direction. For example, for our first set of types, here are two classes, A and B, where B is a subtype of A:

## Getting Real with Kotlin's Reified Type Parameters

DevFeed: [Getting Real with Kotlin's Reified Type Parameters](<https://devfeed.tech/articles/getting-real-with-kotlin-s-reified-type-parameters-25034.md>)

Original publisher: [Read original article](<https://typealias.com/guides/getting-real-with-reified-type-parameters/>)

Author: author@typealias.com (Dave Leeds)

Published: 2017-10-12T02:26:46Z

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>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [compiler](<https://devfeed.tech/tags/compiler.md>), [generic](<https://devfeed.tech/tags/generic.md>), [generics](<https://devfeed.tech/tags/generics.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>), [reification](<https://devfeed.tech/tags/reification.md>), [reified-type-parameter](<https://devfeed.tech/tags/reified-type-parameter.md>), [type-parameter](<https://devfeed.tech/tags/type-parameter.md>), [type-parameters](<https://devfeed.tech/tags/type-parameters.md>)

### AI overview

This Kotlin tutorial explains where generic type parameters can replace concrete class names and where they cannot. It introduces reified type parameters, explaining that they work with inline functions because the function body is expanded at the call site, allowing type comparisons and access to Class objects at runtime.

### Source excerpt

Let's think for a moment about everything that you can do with a class name in Kotlin - think of all the cases where you literally type out the name of a class in your source code. I came up with the following 15 cases, but I probably missed a few. Get your scrolling finger ready, here we go... 1 - Define a member property: private val thing: Thing 2 - Function argument: fun doSomething(thing: Thing) {} 3 - Type argument: val list = listOf<Thing>() 4 - Type parameter constraint: class Item<T : Thing> 5 - Cast to the type: something as Thing 6 - Define the class: open class Thing {} 7 - Extend the class: class Other : Thing() 8 - Import the class: import com.

## Reified Type Parameter

DevFeed: [Reified Type Parameter](<https://devfeed.tech/articles/reified-type-parameter-25021.md>)

Original publisher: [Read original article](<https://typealias.com/concepts/reified-type-parameter/>)

Author: author@typealias.com (Dave Leeds)

Published: 2017-10-07T03:42:19Z

Content type: tutorial

Language: en

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

Topics: [Code](<https://devfeed.tech/topics/code.md>)

Tags: [cast](<https://devfeed.tech/tags/cast.md>), [class](<https://devfeed.tech/tags/class.md>), [code](<https://devfeed.tech/tags/code.md>), [examples](<https://devfeed.tech/tags/examples.md>), [extension-function](<https://devfeed.tech/tags/extension-function.md>), [function](<https://devfeed.tech/tags/function.md>), [generic](<https://devfeed.tech/tags/generic.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>), [property](<https://devfeed.tech/tags/property.md>), [reification](<https://devfeed.tech/tags/reification.md>), [reified-type-parameter](<https://devfeed.tech/tags/reified-type-parameter.md>), [type-parameter](<https://devfeed.tech/tags/type-parameter.md>), [types](<https://devfeed.tech/tags/types.md>), [variance](<https://devfeed.tech/tags/variance.md>)

### AI overview

An explanation of reified type parameters, including how they preserve type information in inline functions, support type checks and casts, and can provide class objects. The article covers single and multiple parameters, extension properties, requirements, alternatives, and code-size considerations.

### Source excerpt

Reified type parameters are type parameters that retain more characteristics of actual types than normal type parameters do. For a gentle introduction to the topic, check out the guide, Getting Real with Reified Type Parameters. Examples Single Parameter inline fun <reified T> Any.isInstanceOf(): Boolean = this is T Here we created an extension function to wrap the more common is operator. Why is this example so magical? Because normally, compiling this is T would result in an error since the type of T is erased.

## When (and when not) to Use Type Parameter Constraints in Kotlin

DevFeed: [When (and when not) to Use Type Parameter Constraints in Kotlin](<https://devfeed.tech/articles/when-and-when-not-to-use-type-parameter-constraints-in-kotlin-25046.md>)

Original publisher: [Read original article](<https://typealias.com/guides/when-to-use-type-parameter-constraints/>)

Author: author@typealias.com (Dave Leeds)

Published: 2017-10-01T20:19:28Z

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>), [Code](<https://devfeed.tech/topics/code.md>), [Cheat sheet](<https://devfeed.tech/topics/cheatsheet.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [cheat-sheet](<https://devfeed.tech/tags/cheat-sheet.md>), [code](<https://devfeed.tech/tags/code.md>), [generic](<https://devfeed.tech/tags/generic.md>), [generics](<https://devfeed.tech/tags/generics.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [parameter](<https://devfeed.tech/tags/parameter.md>), [programming](<https://devfeed.tech/tags/programming.md>), [reference](<https://devfeed.tech/tags/reference.md>), [type-parameter](<https://devfeed.tech/tags/type-parameter.md>), [types](<https://devfeed.tech/tags/types.md>)

### AI overview

This Kotlin tutorial explains how type parameter constraints limit the types accepted by a generic function. It shows how an upper bound lets the function invoke shared properties while preserving the specific return type, and outlines when constraints are useful.

### Source excerpt

Kotlin allows you to constrain a type parameter on a generic when you declare it, limiting the range of types that it can accept. Why is this helpful? Well, let's take a look at an example. Let's say you've got a few pets at home, and you want to pick a favorite: fun <T> chooseFavorite(pets: List<T>): T { val favorite = pets[random.nextInt(pets.size)] // This next line won't compile - because `name` can't be resolved println("My favorite pet is ${favorite.

## Type Parameter Constraint

DevFeed: [Type Parameter Constraint](<https://devfeed.tech/articles/type-parameter-constraint-25025.md>)

Original publisher: [Read original article](<https://typealias.com/concepts/type-parameter-constraint/>)

Author: author@typealias.com (Dave Leeds)

Published: 2017-09-30T01:54:04Z

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>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [classes](<https://devfeed.tech/tags/classes.md>), [examples](<https://devfeed.tech/tags/examples.md>), [function](<https://devfeed.tech/tags/function.md>), [generic](<https://devfeed.tech/tags/generic.md>), [interface](<https://devfeed.tech/tags/interface.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [programming](<https://devfeed.tech/tags/programming.md>), [property](<https://devfeed.tech/tags/property.md>), [syntax](<https://devfeed.tech/tags/syntax.md>), [type-parameter](<https://devfeed.tech/tags/type-parameter.md>), [type-parameters](<https://devfeed.tech/tags/type-parameters.md>), [types](<https://devfeed.tech/tags/types.md>), [variance](<https://devfeed.tech/tags/variance.md>)

### AI overview

This Kotlin article explains type parameter constraints: how upper bounds restrict accepted type arguments while preserving type information, how to apply constraints to interfaces, classes, functions, and extension properties, and how to express single or multiple constraints using concise and verbose syntax.

### Source excerpt

Overview Type parameter constraints allow you to limit the types that can be accepted as a type argument to an upper bound, giving you the ability to invoke functions and properties on an object while preserving the type. If that sounds confusing, go check out the guide, When to Use Type Parameter Constraints, which walks through the use cases in more detail. In this article, we're going to look at the variety of ways that you can create a type parameter constraint in Kotlin.

## RecyclerViewUtils Library Released

DevFeed: [RecyclerViewUtils Library Released](<https://devfeed.tech/articles/recyclerviewutils-library-released-22830.md>)

Original publisher: [Read original article](<http://androidessence.com/recyclerviewutils-library-released/>)

Author: Adam McNeilly

Published: 2016-08-31T00:00:00Z

Content type: release

Language: en

Sources: [Android Essence](<https://devfeed.tech/sources/android-essence.md>)

Topics: [Library](<https://devfeed.tech/topics/library.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [generic](<https://devfeed.tech/tags/generic.md>), [library](<https://devfeed.tech/tags/library.md>), [recyclerview](<https://devfeed.tech/tags/recyclerview.md>)

### AI overview

The article announces the RecyclerViewUtils personal library, which provides CoreViewHolder and CoreAdapter classes to reduce repetitive RecyclerView adapter code. It explains how generic types and shared methods simplify object binding and adapter operations.

### Source excerpt

Recently, I became tired of writing the same old tedious code for every single RecyclerView and Adpater class I used, that all did the same thing, so I extrapolated all of it into a personal library. The RecyclerViewUtils library helps make everyone's life a little easier with a CoreViewHolder and CoreAdapter class, described below.