News for hackers. Stuff that matters.
Re:Flutter: the good, the bad and the ugly by brianpgordon on Sunday November 25, 2018 @02:02AM (#18525762)
Invariant generics would at least let you rely on the type system doing its job correctly. But even better would be to annotate each type parameter as covariant, contravariant, or invariant - this is what Scala and C# and probably a bunch of other languages do.

As an example, here's approximately how the Function trait is defined in Scala. The square brackets indicate type parameters (like angle brackets in Java), the - indicates covariance, and the + indicates contravariance.

  trait Function1[-T, +R] {
      def apply(arg1: T): R
  }

There are no comments on this comment yet.