Kev
02/07/2024, 7:29 AMTies
02/07/2024, 7:54 AMsimon.vergauwen
02/07/2024, 7:58 AMAny?
, not Any
so everything generic is nullable but when inserting a Int?
you get a nested null. Project Reactor, and/or RxJava, choose to use null
as an internal optimisation mechanism and as a result they do not allow null
as a value for T
. There you have to resort to Option
or Java's Optional
to allow such a pattern of absent values.
However, in Kotlin (and with KotlinX Flow) this is never really needed. In generic code you can avoid this problem, or work around it.
Here is an in detail explanation on the website, https://arrow-kt.io/learn/typed-errors/nullable-and-option/