When I'm trying to affect a value of type String in a field of type Option[String] I get the following error :
type mismatch; found : String required: Option[String]
How can I affect value myValue:String into field myField:Option[String] ?
When I'm trying to affect a value of type String in a field of type Option[String] I get the following error :
type mismatch; found : String required: Option[String]
How can I affect value myValue:String into field myField:Option[String] ?
If you want to convert empty string to None more universal solution is: Option(str).filter(_.nonEmpty)