🎁📦💝🎁📦💝🎁📦💝
Unwrap nullable variables
repositories {
jcenter()
}
dependencies {
compile "com.importre:kotlin-unwrap:<VERSION>"
}
// returns nullable
fun foo(name: String?): String? = name
val _a = foo("Hello")
val _b = foo("World")
val _c = foo("!")
// example: unwrap all variables
unwrap(_a, _b, _c) { a, b, c ->
println("$a, $b$c") // invoked
}
val _a = foo("Hello")
val _b = foo("World")
val _c = foo(null)
// example: error handing
unwrap(_a, _b, _c) { a, b, c ->
println("$a, $b$c") // not invoked
} otherwise {
println("Nah!") // invoked because `_c` is null
}
$ ./gradlew check
Apache 2.0 © Jaewe Heo