generic classes

Generic Traits and Classes With Type Parameters And Variance

Reading Time: 4 minutes Variance is the correlation of subtyping relationships of complex types and the subtyping relationships of their component types. Scala supports variance annotations of the type parameters of generic traits and classes.

Scala: Generic classes and Variance

Reading Time: 4 minutes Generic classes are classes which take a type as a parameter. This means, one class can be used with different types without actually writing down it multiple times. They are particularly useful for collection classes. Defining a generic class: Generic classes take a type as a parameter within square brackets [ ]. One convention is to use the letter A as type parameter identifier, though Continue Reading