Retrieve none from list of options
I have multiple options. I want to check if they hold the value. If any of
these Options is None, i want to reply to user about this. If all well,
then proceed forward.
This is what I have done:
val name:Option[String]
val email:Option[String]
val pass:Option[String]
val i = List(name,email,pass).find(x => x match{
case None => true
case _ => false
})
i match{
case Some(x) => Ok("Bad Request")
case None => {
//move forward
}
}
But this is a very very dirty way. How can I make it elegant
No comments:
Post a Comment