3 ms·
On the contrary, the power of Scala types means you are less likely to get in a case where the compiler blocks you despite your code being safe. See the exampl
by eloisant 3y ago
On the contrary, the power of Scala types means you are less likely to get in a case where the compiler blocks you despite your code being safe.
See the example of the article, where you don't have covariance in Go and the compiler fails. Same in Java where you have to cast (and add unsafety) to make the compiler accept your code.
In Scala when using immutable structure (the default) you have covariance and the compiler will happily let you call a function that takes a List[A] with a List[B] if B extends A.
Now that's true that you can do overly complex things with Scala types, but you don't have to.