I want to get the value of one of several Option in scala, like this:
def or(a:Option[Int], b:Option[Int]):Option[Int]=
if (a.isDefined) a else b
val a= Option(1)
val b= Option(2)
or(a,b).get
but I wonder why isn't the ||
operator defined for Option? Is there a more idiomatic way of doing this?