Dart unfortunately lacks (by design) the ability to specify invariant or contravariant type parameters. So when I need them, how do I work around thei ...
Dart unfortunately lacks (by design) the ability to specify invariant or contravariant type parameters. So when I need them, how do I work around thei ...
TypeScript doesn't seem to infer contravariance. Here is an example that illustrates the inconsistency: class Base { base = "I'm base" } class Der ex ...
From this video by Functional Programming Principles in Scala "4.5 Variance" you can see a slide that says, Translated: Say you have two function ...
I have a question on when to use type parameterization vs base class type when defining a method/class in Scala especially when the types allowed are ...
I started off with a simple generic interface: However I needed to make this interface's generic type covariant (for reasons I won't go into), howe ...
There's the following interface which defines a packet. There are two implementations, each with its own additional property. The above is libra ...
I've been recently learning Kotlin, while having some questions with covariant type. The sample code is here. I have Option and Option2 both having a ...
This doesn't compile: Alright, fair enough. But this does compile: Which lets us circumvent whatever problems the variance checks are giving us: ...
I have the following piece of code where I am trying to write a generic validation rule for my domain objects. while doing so I have an issue to deal ...
Recently I ran into a problem where I had a function which had to return an Array of Is, in form of all values of enum E, with E implementing interfac ...
I have a question that's been bugging me. Lists in Scala are covariant (List[+A]) Let's say we have these classes: The map function of List[B] tak ...
I'm trying to write some validatable form interface in Kotlin. In the validation part I'm using https://github.com/kamedon/Validation. Here is the ve ...
For the above mentioned code I understand that copy function expects both type parameters of exactly same type. With a slight modification copy(src: ...
I feel like interface (contra?)variance is the answer, but cannot find the right solution. Let us have these classes: My situation being: I ha ...
I have the following Kotlin classes implementing something similar to the Collections interface or a set that contains multiple elements. So instan ...
In the following sample, I can pass a Consumer<Optional<Integer> to foo, but not a Consumer<Optional<Number>>. On the other hand, ...
I'm new to Kotlin. When I learn Storing Properties in a Map. I try following usage. The first two are both work, the last one failed. Wit ...
I'm having difficulty writing something that should be quite straight-forward, but I can't seem to get the syntax right. I have a class hierarchy for ...
In coursera functional programming course, I came across a subtle concept. If A2 <: A1 and B1 <: B2, then (A1 => B1) <: (A2 => B2) Ju ...
Please see error messages in comments: Key points: bookPrint() and authorPrint() both need to take a null book/author printIt() needs to take ...