Tuang
12/23/2019, 9:46 PMval carMst: List<(Mutable)Map<String!, Any!>!>!
val carUserIds: List<(Mutable)Map<String!, Any!>!>!
....
....
val result = ArrayList<Car>()
for (mst in carMst) {
val userIds = ArrayList<Int>()
for (uids in carUserIds) {
if (mst["car_id"] == uids["car_id"]) {
userIds.add(uids["user_id"] as Int)
}
}
val car = Car(
mst["car_id"] as Int,
mst["model"] as String,
userIds
)
result.add(car)
}
i dont know too much about collection and lambda but with collection this can be more simple and beautiful right? 😀
thanksShawn
12/23/2019, 10:04 PMMap<String, Any>
representative of some kind of Car
-related record stored somewhere? You should consider migrating from weakly-typed maps to something more explicit and harder to coerce improperlyif (carMst["car_id"] == uids["car_id"])
supposed to be if (mst["car_id"] == uids["car_id"])
? carMst
is a list here and cannot be accessed using a stringO(mn)
solution here, but there very well might be oneas
here is also pretty susTuang
12/23/2019, 11:33 PM