I have a List
val shoeCart = ShoeRepository.getShoeFromCart(this@ActivityCart)
from ShoeRepository
fun getShoeFromCart(context: Context): List<ShoeModel> {
return getCart(context)
}
ShoeModel is a data class
data class ShoeModel
I want to find out if my shoeCart has duplicate entries in it, and if it does, how many?
Data classes have their
equalsmethod implemented, so we can useeachCountMap extension to map values to their quantities.The output of this snippet is
{ShoeModel(someProperty=1)=2, ShoeModel(someProperty=2)=2}.