Checking if values in List is part of String

前端 未结 2 1926
隐瞒了意图╮
隐瞒了意图╮ 2020-12-13 17:47

I have a string like this:

val a = \"some random test message\"

I have a list like this:

val keys = List(\"hi\",\"random\",         


        
2条回答
  •  醉梦人生
    2020-12-13 17:57

    Something like this?

    keys.exists(a.contains(_)) 
    

    Or even more idiomatically

    keys.exists(a.contains)
    

提交回复
热议问题