Created
December 28, 2021 11:54
-
-
Save chaitanyagupta/4fb425c716305a9cec91b9c80ad41079 to your computer and use it in GitHub Desktop.
Name shadowing in Kotlin
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
// This simple example shows that name shadowing in Kotlin depends on type specificity | |
// | |
// Foo().baz(1) after evaluating this class returns 43 | |
class Foo() { | |
fun bar(x: Int): Int = x + 42 | |
fun baz(bar: Int): Int = bar(bar) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment