Scala: Convert if to case
I have following code segment I am still learning Scala and haven't really
use case within-case: but I want to convert the if statement that I have
to more scala way of doing things:
...
.flatMap {
case(a, b, c, d, e, f, g, h) =>
val tiitleSubTitle = (title + " " + subtitle).split("\\s").toSet.toList
tiitleSubTitle.map(term => (
if (a contains term)
{
Some(query, term, List(item_id).mkString(","))
} else {
None
}))
}
No comments:
Post a Comment