Closed damien7792 closed 1 year ago
In this case, itemDao.getAllItems() is returning a Flow (of type Flow<List
@cjparent Thank you for the reply.
@damien7792 Hope that answers your question. Please let us know, if you have any other questions.
@cjparent Sorry for the late reply. Yes thanks, that makes sense!
URL of codelab: https://developer.android.com/codelabs/basic-android-kotlin-compose-update-data-room?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-6-pathway-2%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-update-data-room#7
In which task and step of the codelab can this issue be found? In the CodeLab "Read and update data with Room", step 8 "Implement sell item" Then, in point 4: "Retrieve the entities with itemDao.getAllItems(). Compare them to the updated entity and assert."
Describe the problem It's not really a problem, but I'm puzzled by something: the ".first()" operator that seems to return a list. I come from the .Net world, and in C# when you end a series of instructions with ".First()", you expect to get back a single item, not a list. Here, it seems that by ending with ".first()", "allItems" contains a list of items: we can access allItems[0] and allItems[1]
Can you clarify how the "first()" operator works in that case?
Thank you!