Scala check if element is present in a list

后端 未结 6 1952
刺人心
刺人心 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:03

    this should work also with different predicate

    myFunction(strings.find( _ == mystring ).isDefined)
    

提交回复
热议问题