I have: ox: Option[A] and oxs: Option[List[A]].
I would like to:
Return
ox.get :: oxs.getif both existed.Return
List(ox.get)ifoxexisted andoxsdid not.Return
oxs.getifoxsexisted andoxdid not.Return
List()if both areNone.
I can achieve this with ifs and matches. I was just wondering if there was any elegant idiomatic way of doing it?
EDIT: I have tested: List(ox.map(List(_)), oxs).flatten.flatten and it seems to work for all four cases, but it still looks a bit hard to understand.