Can a MutableList have items of two different (obj...
# android
s
Can a MutableList have items of two different (object) type? If not what are my alternatives?
a
mutableList<Any>
👍🏽 1
p
Do they have a common base class, use the base class instead of Any if so
☝️ 1
c
@Sudhir Singh Khanger Note that there are very few cases where
List<Any>
is the right solution, feel free to share your code if you need some help
s
Thanks everybody. @cedric I am learning Kotlin by writing a Udacity Android Nanodegree project. I need to pass two simple model classes to a heterogeneous-RecyclerView Adapter. I am passing them as one MutableList. I am not very familiar with the collections class in Kotlin. That's on my list once I finish this sample app. https://github.com/sudhirkhanger/baking-app-kotlin