Closed svby closed 6 years ago
Sorry, this issue totally went under my radar.
I'm afraid we can't make it Optional<Any?>
. In Koptional null
means None
.
By allowing to hold Some(null)
we will break a lot of existing use cases as well as functions that we provide:
Optional.toNullable() right now only returns
nullif it is
None`fun <T : Any> T?.toOptional()
will be broken completely, as right now it returns None
if you call it on a null
valueI'm going to close the issue for now, please feel free to comment, we might reopen it in future :)
Currently, the type parameter of
Optional
is constrained to not be nullable; however, if it weren't, it would allow an important distinction between no value and not present (e.g.: deserializing data).Would this be possible (or make sense), and would it fit the design goals of this library?