Last active
September 29, 2017 00:02
-
-
Save objcode/d1dbeb96d5999c8741d990e057165839 to your computer and use it in GitHub Desktop.
Kotlin type puzzle
This file contains hidden or 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
// In the following declaration, what happens when you call fn()? | |
val fn: () -> Unit = { "I am not a string" } | |
// Due to inference, the lambda is evaluated to return Unit and the string is discarded. It is as if you typed, | |
fun fn(): Unit { | |
"I am not a string" | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment