I have an Option[String].
I want to check if there is a string exists and if it's exists its not blank.
def isBlank( input : Option[String]) : Boolean =
{
input.isEmpty ||
input.filter(_.trim.length > 0).isEmpty
}
Is there is a better way of doing this in Scala ?
What you should do is check using exists. Like so:
myOption.exists(_.trim.nonEmpty)
which will return True if and only if the Option[String] is not None and not empty.