0

I have two option:

val opt1: Option[Long] = //
val opt2: Option[Long] = //

I need to combine it into opt3 such that

opt3 = opt1 if !opt1.isEmpty
opt3 = opt2 if opt1.isEmpty && !opt2.isEmpty
opt3 = None otherwise

Is there a more concise way than writing if-elses?

St.Antario
  • 26,175
  • 41
  • 130
  • 318

0 Answers0