Skip to content

Instantly share code, notes, and snippets.

@chaitanyagupta
Created December 28, 2021 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chaitanyagupta/4fb425c716305a9cec91b9c80ad41079 to your computer and use it in GitHub Desktop.
Save chaitanyagupta/4fb425c716305a9cec91b9c80ad41079 to your computer and use it in GitHub Desktop.
Name shadowing in Kotlin
// 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