I'm using the Option Type's isEmpty
method to check if there is no value. I do not want to use the case
match
as in my situation, I just want to check if there is None
as I would throw an error to the caller. But the isEmpty
method fails even though the value is None
.
Here is what I tried!
val questionOption = Question.getQuestionForQuestionId(userExam.get.examId, currQuesId + 1)
if(questionOption.isEmpty) {
Left(Failure(FailureCode.NO_DATA_FOUND, "Cannot get next exam question you tampered your cookie or cookie is lost.... >> TODO... modify the exception message"))
}
It is not getting inside the if condition. I tried to do a println on the questionOption and it prints None. So wondering why I'm not getting inside the if condition.
case object None extends Option[Nothing] { def isEmpty = true; ...}
– Prince John Wesley