P A
10/15/2023, 6:12 PMdata class Foo(val bar: Option<String?>)
Foo("the value".some())
Foo(null.some()))
Foo(none())
fun main() {
when (val bar = Foo(Some("string")).bar) {
None -> TODO()
is Some -> TODO()
}
}
The arrow documentation says “There are only a few cases where you should use Option
instead of nullable types, and one is the nested nullability problem.” I’m wondering if this group consider this use case a valid one or if there other aspects I should be aware of (e.g., explicitly use the Some
or .some()
constructor).mitch
10/16/2023, 2:09 AMOption<Option<A>>
as well. Although conceptually I think Option<T?>
is probably more representative because null
here is passed as a non-absent valueP A
10/17/2023, 9:15 PM