Andreas Sinz
05/14/2018, 8:51 PMBox<T>
is invariant, that means Box<Int>
is not a subtype of Box<Number>
https://proandroiddev.com/understanding-generics-and-variance-in-kotlin-714c14564c47kiptoo
05/15/2018, 7:16 AMopen class Box<out T>(t: T) {}
, but what if some of my functions in Box need to take in parameters of type (or subtype) T, e.g Box.createBox(box: Box<T>)
?Andreas Sinz
05/15/2018, 11:58 AMT
only occurs in the in-position or out-position, not both at the same time, otherwise you could create code that fails at runtimekiptoo
05/15/2018, 2:25 PM