Scala check if element is present in a list

后端 未结 6 1810
刺人心
刺人心 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 19:52

    In your case I would consider using Set and not List, to ensure you have unique values only. unless you need sometimes to include duplicates.

    In this case, you don't need to add any wrapper functions around lists.

提交回复
热议问题