I have a list like this:
val list = List<FlightRecommendationQuery>
in that:
data class FlightRecommendationQuery(
val segments: List<Segment>
)
data class Segment(
val stops: Int?
)
I have another list with size same as segments size in FlightRecommendationQuery called filter:
val filter = List<Filter>
data class Filter(
val stops: Int?
)
I want to filter 'list' when filter's stops are equal to each segments in list. Here, size of list 'filter' and size of 'segments' of FlightRecommendationQuery are same.
Update: I concluded with this solution:
list.filter{query->
filter.indices.all{
if(filter[it].stops==null) true
else
filter[it].stops==query.segments[it].stops
}
}