Skip to content

Instantly share code, notes, and snippets.

@jdsingh
Last active April 1, 2018 18:52
Show Gist options
  • Save jdsingh/2796261bd52bba936f9c02c8e3c188a3 to your computer and use it in GitHub Desktop.
Save jdsingh/2796261bd52bba936f9c02c8e3c188a3 to your computer and use it in GitHub Desktop.
fun outerFunction(nice: String) {
val hello = "Hello, world"
fun innerFunction(awesome: String) {
println(awesome)
// we can access arguments of outer function
println(nice)
// and we can also access variables declared in outer functions
println(hello)
}
// invoking inner function
innerFunction("This is awesome")
}
fun main(args: Array<String>) {
// we can access outerFunction but not innerFunction outside of the
// outerFunction's scope
outerFunction("This is nice")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment