home search about rss feed twitter ko-fi

Introduction to Scala Types, Part 2 (Variance) (Video)

In this free Scala training video I continue to provide an introduction to Scala types, this time primarily focusing on Variance when using generic types.

Like C# and Kotlin, Scala uses declaration-site variance, and in this video I describe variance as related to whether the type is used as a Producer, Consumer, or both. In C# and Kotlin, producer types are annotated with the out keyword, and consumer types are annotated with the in keyword, and I think that’s easier to understand, especially when you first start working with variance.

I also explain variance with how it’s used in the Scala collections classes, like List, ArrayBuffer, and other types.

Update: All of my new videos are now on
LearnScala.dev