Syed Faraz
07/16/2019, 9:10 AMsealed class Operation <out T> {
data class InsertOperation<out T>(var insertedData: ArrayList<T>)
}
Hi, this gives type parameter t is declared as 'out' but occurs in 'invariant' position in type t
, can anyone tell me what is correct way of handling this type of variance checking?diesieben07
07/16/2019, 9:12 AMout
parameter means you are only getting values of that type out of the class. But ArrayList
permits writing. Use a List<T>
, which is not modifiableSyed Faraz
07/16/2019, 9:15 AMdiesieben07
07/16/2019, 9:16 AMinsertedData
declared as a var
, which means you can, again, put data in.max
07/16/2019, 9:41 AM<out T>
really necessary?Syed Faraz
07/16/2019, 9:46 AMdata class InsertOperation<out T>(val insertedData: List<T>) :Operation<T>
it'll be something like thismax
07/16/2019, 10:51 AM