kotlin-inline-class

Is it possible to make safe inline Optional in Kotlin?

穿精又带淫゛_ 提交于 2020-01-13 06:39:08
问题 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