rewrite
rewrite copied to clipboard
Swap `filter()` and `map()`
Before :
incidents.stream().filter(e-> e.getIncidentID().equalsIgnoreCase("123").map(Results::getIncdntId)
After :
incidents.stream().map(Results::getIncdntId).filter(e-> e.equalsIgnoreCase("123"))
Hi @yeikel! I think there may be a typo in the After
.
The map would return the values from Object#get()
, so the filter can only act on the mapped objects.
So, in this case the filter should be e -> e.equalsIgnoreCase("123")
;
I'll add it to recipes wanted, and mark it for uses-dataflow
.
Thanks!
Hi @yeikel! I think there may be a typo in the
After
. The map would return the values fromObject#get()
, so the filter can only act on the mapped objects. So, in this case the filter should bee -> e.equalsIgnoreCase("123")
;I'll add it to recipes wanted, and mark it for
uses-dataflow
. Thanks!
That's correct. I updated it
Thanks!