I understand the concept. None
I also understand how good it is to have MyObjas well MyEmptyObj, but I cannot understand when it is better to use Noneinstead MyEmptyObjand when I should use MyEmptyObjinstead None. In addition, I do not like to see methods that return Option[MyObj], it clutters up my code, which I prefer to return MyObj, and then easily calls its methods, such as MyObj.toJson, and therefore MyEmptyObj.toJsonwill know to represent itself, and not to have case None: return some empty jsonWhat do you think of this subject? On the other hand, I can say that it Nonegoes well with flatMap, etc., why choose?
when None
and when Empty?
source
share