Created
October 5, 2018 08:58
-
-
Save dgreenhalgh/54d87412fec2705119a72bd08e12fbe6 to your computer and use it in GitHub Desktop.
Big Nerd Ranch Anonymous Functions - SimVillage
This file contains 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
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