withFilter instead of filter

前端 未结 6 975
我寻月下人不归
我寻月下人不归 2020-11-28 07:05

Is it always more performant to use withFilter instead of filter, when afterwards applying functions like map, flatmap etc.?

Why are only map, flatmap and fore

6条回答
  •  一向
    一向 (楼主)
    2020-11-28 07:50

    For the forall/exists part:

    someList.filter(conditionA).forall(conditionB)
    

    would be the same as (though a little bit un-intuitive)

    !someList.exists(conditionA && !conditionB)
    

    Similarly, .filter().exists() can be combined into one exists() check?

提交回复
热议问题