sarthak sarthak - 11 months ago 39
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")) ... })