Created
March 10, 2020 21:26
-
-
Save helenwilliamson/55bc6d0b0f442bc305174f7024430d27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Bob(val name: String, val live: Live) | |
data class Live(val value: Boolean) { | |
companion object { | |
fun apply(value: String?): Boolean = | |
value.let { | |
if (it.isNullOrBlank()) null else it | |
}?.toBoolean() ?: false | |
} | |
} | |
val a = Bob("sandwich", Live(true)) | |
Live.apply(null) | |
Live.apply("") | |
Live.apply("true") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment