If I have an Option[Int]
and a function validateInt(i: Int): Boolean
. I want to do something if the option is empty or if it passes the validation.
I know it can be done with
if (opt.forall(validateInt)) {
// do something
}
Is there a more functionally idiomatic way to do this in Scala?