Skip to content

Instantly share code, notes, and snippets.

View TarodBOFH's full-sized avatar
🌆
Starting new things!

Juan Ara TarodBOFH

🌆
Starting new things!
View GitHub Profile
fun main() {
// You can do this
val assignment = null ?: false
val fromBlock = when(assignment) {
true -> true
false -> null
} ?: false
// Or this
val computed = if (fromBlock && assignment) { true } else { null }
// see the outputs
fun main() {
println(null != null ?: false)
val first = null // we don't know the type of this guy
val second = null ?: false // this guy is a boolean!
println(first != second)
var notNullableGuy = first != second // this guy is a non nullable boolean
notNullableGuy = false // we can do this
println(notNullableGuy)
}
fun main(args: Array<String>) {
println(null != null ?: false)
}