Created
May 20, 2022 03:43
-
-
Save HWilliamgo/d7e586a0d158ec6e29e784d20088af81 to your computer and use it in GitHub Desktop.
[Kotlin elvis] #Kotlin
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
object StringProducer { | |
fun produce(): String? { | |
return "abc" | |
} | |
} | |
fun main() { | |
StringProducer.produce()?.let { | |
println(it) | |
} ?: run { | |
println("StringProducer.produce() return empty") | |
} | |
val s = StringProducer.produce() | |
if (s != null) { | |
println(s) | |
} else { | |
println("StringProducer.produce() return empty") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment