Last active
October 13, 2021 13:59
-
-
Save himattm/9e2a61c2ebce53aacf3a670960765e5b to your computer and use it in GitHub Desktop.
Today we have a Kotlin brain teaser! What does this code print?
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
data class Foo(val i: Int) | |
fun main() { | |
val map = mapOf( | |
1 to Foo(1), | |
2 to Foo(2), | |
3 to Foo(3), | |
) | |
println("map = $map") | |
println("map[1] is Foo = ${map[1] is Foo}") | |
println("map[0] is Foo = ${map[0] is Foo}") | |
println("map[0] is Foo? = ${map[0] is Foo?}") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment