Skip to content

Instantly share code, notes, and snippets.

@amatkivskiy
Last active May 15, 2020 04:38
Show Gist options
  • Save amatkivskiy/1f97c144fb876c39aab6ca368a1c9684 to your computer and use it in GitHub Desktop.
Save amatkivskiy/1f97c144fb876c39aab6ca368a1c9684 to your computer and use it in GitHub Desktop.
data class Parent(val child: Nested?)
class Nested(val child: Nested?, val isValid: Boolean = false)
// Assume you got this object from the dark and deep internals of your app
val parentObj = getParentObjFromInternals()
doSomethingOnBooleanValue(parentObj.child?.child?.child?.isValid)
fun doSomethingOnBooleanValue(valid: Boolean?) {
if (valid == true) {
// `valid` is really true
} else {
// `valid` is false or null
}
}
fun getParentObjFromInternals() = Parent(Nested(Nested(Nested(null, true))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment