Just out of interest - back in the days when Kotli...
# compiler
r
Just out of interest - back in the days when Kotlin was first designed was there any discussion about making covariant generic types the default, with invariant & contravariant requiring extra syntax? My gut feel is that most people expect
Foo<String>
to be a subtype of
Foo<Any>
, and if you favour immutable data types then covariance often Just Works™. I try and remember to use
<out T>
as my starting point, until I need something else, but I often forget...
e
I don't know, but defaulting to
<out T>
only makes sense for immutable types
r
Yup, but I think there's a case, in the spirit of nudge, for biasing the language towards immutable types.