You know that for-comprehension can be used for Option. What happens if it is applied to None?
def countNonEmptyLength(stringOpt: Option[String]): Option[Int] =
for
string <- stringOpt
if string.nonEmpty
yield string.size
countNonEmptyLength(None)