Well, this is clear from the errors and types that x.email are not String ...
First decide how you want to handle None (a valid option for something like Option[String] ). Then you have a number of options, including but not limited to:
x.email match { case None => ... case Some(value) => println(value)
Alternatively, check out the get and getOrElse on the class Option .
If you want to "degrade" a parameter in String with a possible null value, use
x.email.orNull // calls getOrElse(null)
Finally, if you just don't care about the None case (and want to ignore it), just use a simple โto understandโ that will โskipโ the body in the None case:
for (value <- x.email) { // value is of type String }
Richard Sitze
source share