hello! I have a (hopefully) simple question regard...
# arrow
s
hello! I have a (hopefully) simple question regarding dealing with multiple
Option
values
Copy code
val option1 = Option.just("foo")
    val option2 = Option.just(1)
    val option3 = Option.just(Bar())

    val result: Option<FooBar> = option1.flatMap { unwrappedValue1 ->
        option2.flatMap { unwrappedValue2 ->
            option3.map { unwrappedValue3 ->
                FooBar(unwrappedValue1, unwrappedValue2, unwrappedValue3)
            }
        }
    }
}
what is a better way to handle the use case where you want to return an
Option
that is, for example, a composite of multiple other types that are wrapped by
Option
I would like the resulting
Option
to be
None
if any of the other values are
None
, otherwise return
Some
that is a composite of the data from the other `Option`s…if that makes sense?
I’m relatively new to functional programming concepts, so I have a feeling there’s a term for what I’m trying to do. I just don’t know what it’s called 😛