KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I guess, "type variance annotations" ( + and - ) cannot be applied to "type members". In order to explain it to myself I considered the following example abstract class Box {type T; val element: T} Now if I want to create class StringBox I have to extend Box : class StringBox extends Box { type T = String; override val element = ""} So I can say that Box is naturally covariant in type T . In other words, the classes with type members are covariant in those types. Does it make sense ? How would you describe the relationship between type members and type variance ?
Tags (comma-separated)
Save Edits
Cancel