https://kotlinlang.org logo
Title
c

chickenfresh

08/25/2018, 5:29 PM
how can I use .find with data class inserted into sealed class?
d

diesieben07

08/25/2018, 5:30 PM
It's not really clear what you want to achieve.
find
works on collections.
c

chickenfresh

08/25/2018, 5:34 PM
@diesieben07okay look at this then
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:
sealed class AnotherViewInstance {
    data class Item(val item: ItemModel): AnotherViewInstance()
}
d

diesieben07

08/25/2018, 5:37 PM
Like this?
itemsList.find { it is AnotherViewInstance.Item && it.id == 1 }
c

chickenfresh

08/25/2018, 5:47 PM
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

diesieben07

08/25/2018, 5:48 PM
Sure
👍 1