Is it possible to make safe inline Optional in Kotlin?
问题 In Kotlin sometimes I have to work with double nullability. For example, I need double nullability, when I want to use T? where T may be a nullable type. There are a few approaches for doing this: Holder<T>? where Holder is data class Holder<out T>(val element: T) - example 1 boolean flag variable - example 1 containsKey for Map<K, T?> - example 1 The special UNINITIALIZED_VALUE for representing the second kind of null - example 1 The last approach has the best performance, but it's also the