Scala check if element is present in a list

后端 未结 6 1822
刺人心
刺人心 2021-01-30 19:45

I need to check if a string is present in a list, and call a function which accepts a boolean accordingly.

Is it possible to achieve this with a one liner?

The c

6条回答
  •  长情又很酷
    2021-01-30 20:07

    And if you didn't want to use strict equality, you could use exists:

    
    myFunction(strings.exists { x => customPredicate(x) })
    

提交回复
热议问题