Is there a more idiomatic/simpler way to write this code that deals with two Options?
object Test extends App {
val colors = Some(1)
val sizes = Some(2)
val ids = colors match {
case None => {
sizes match {
case None => getRegularIds
case Some(sizes) => getSizeIds
}
}
case Some(colors) => {
sizes match {
case None => getColorIds
case Some(sizes) => getColorIds ++ getSizeIds
}
}
}
println(ids)
def getColorIds = Seq(1,2,4)
def getSizeIds = Seq(4,5,6)
def getRegularIds = Seq(7,8,9)
}
Scala is so concise that it leads me to think there's probably a cleaner way to achieve the same results.