Skip to content

Instantly share code, notes, and snippets.

@dgreenhalgh
Created October 5, 2018 08:58
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 dgreenhalgh/54d87412fec2705119a72bd08e12fbe6 to your computer and use it in GitHub Desktop.
Save dgreenhalgh/54d87412fec2705119a72bd08e12fbe6 to your computer and use it in GitHub Desktop.
Big Nerd Ranch Anonymous Functions - SimVillage
fun main(args: Array<String>) {
runSimulation()
}
fun runSimulation() {
val greetingFunction = configureGreetingFunction()
println(greetingFunction("Guyal"))
}
fun configureGreetingFunction(): (String) -> String {
val structureType = "hospitals"
var numBuildings = 5
return { playerName: String ->
val currentYear = 2018
numBuildings += 1
println("Adding $numBuildings $structureType")
"Welcome to SimVillage, $playerName! (copyright $currentYear)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment