how can I use .find with data class inserted into ...
# announcements
c
how can I use .find with data class inserted into sealed class?
d
It's not really clear what you want to achieve.
find
works on collections.
c
@diesieben07okay look at this then
Copy code
val itemsList = FXCollections.observableArrayList<itemModel>()

itemsList.find { it.id == 1 }
ItemModel
contains
val id: Int
so how should look working example if I’d put
ItemModel
into
sealed class
like this:
Copy code
sealed class AnotherViewInstance {
    data class Item(val item: ItemModel): AnotherViewInstance()
}
d
Like this?
itemsList.find { it is AnotherViewInstance.Item && it.id == 1 }
c
Yes, thanks a lot, forgot about it. Is
when
also an option in case If i’d need to use it with another data class?
d
Sure
👍 1