sarthak sarthak - 1 year ago 85
Scala Question

Error while trying to Iterate over List of Strings

I have an RDD of form

. I am trying to check if the string "Bethan" is a part of the
. I wrote the following line in scala:

val disOneRdd => {if(x._2._2.contains("Bethan")) (x._1,(1,x._2._2)) else x})

But I am getting the following error:

value contains is not a member of Iterable[String].

How can I check if the string is present in the list or not?

Answer Source

Convert to list:

val disOneRdd => {if(x._2._2.toList.contains("Bethan")) ... })
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download