Mani
11/12/2019, 9:20 AMdiesieben07
11/12/2019, 9:20 AMArrayList in the first place? It is not defined which list implementation is returned by these methods.Mani
11/12/2019, 9:21 AMdiesieben07
11/12/2019, 9:21 AMArrayList(<existing list>), which creates another copy.diesieben07
11/12/2019, 9:22 AMList, MutableList) whenever possible.Dipali
11/12/2019, 9:22 AMl2.distnct() with your sample data then it is a String "A" and String cannot be casted directly to ArrayList<String>Mani
11/12/2019, 9:23 AMMani
11/12/2019, 9:23 AMdiesieben07
11/12/2019, 9:23 AMbezrukov
11/12/2019, 9:24 AMList<T>Mani
11/12/2019, 9:25 AMHowever if possible you should adjust those methods, code against interfaces (`List`, `MutableList`) whenever possible. why should I refactor to List and MutableList? @diesieben07diesieben07
11/12/2019, 9:27 AMdiesieben07
11/12/2019, 9:28 AMArrayList, even though it really only needs a MutableList or even just a List. That limits your ability to use this methodDipali
11/12/2019, 9:28 AMl2.distinct().toList()diesieben07
11/12/2019, 9:28 AMArrayList, even if its already a Listdiesieben07
11/12/2019, 9:29 AMList, not ArrayList.Dipali
11/12/2019, 9:32 AMl2.distinct() can't be casted directly then a.distinct().toList() will be available for casting without any exception; despite this all I still wonder the return type of distinct is List<T> and should work directly.diesieben07
11/12/2019, 9:32 AMdistinct is List. That means it can return something other than ArrayList.diesieben07
11/12/2019, 9:33 AMdiesieben07
11/12/2019, 9:33 AMtoList.thanksforallthefish
11/12/2019, 9:33 AMtoList() does not guarantee the underline implementation is Arraylist. it might work today, but the contract is to just have a List, kotlin stdlib can change implementation any time and the cast would failMani
11/12/2019, 9:37 AMMani
11/12/2019, 9:37 AMbezrukov
11/12/2019, 9:39 AMArrayList(.....distinct()) ?thanksforallthefish
11/12/2019, 9:40 AMMani
11/12/2019, 5:04 PM