Marcin Wisniowski
09/06/2023, 11:09 PMitem is A || item is B || item is C || item is D
?Joffrey
09/06/2023, 11:11 PMitem
subject, you could use a when
like this:
when (item) {
is A, is B, is C, is D -> doTheThing()
else -> dontDoTheThing()
}
Joffrey
09/06/2023, 11:12 PMitem
is of the parent type (e.g. a sealed interface)Marcin Wisniowski
09/06/2023, 11:13 PMfilter {}
Marcin Wisniowski
09/06/2023, 11:14 PMJoffrey
09/06/2023, 11:14 PMJoffrey
09/06/2023, 11:15 PMJoffrey
09/06/2023, 11:15 PM.filterIsInstance<TheParentInterface>()
which yields a list of the new element type, which allows to make use of this information further down the pipelineMarcin Wisniowski
09/06/2023, 11:17 PMJoffrey
09/06/2023, 11:17 PM