Skip to content

Instantly share code, notes, and snippets.

@scottashipp
Last active May 28, 2019 19:29
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 scottashipp/28eec8431413717662b2 to your computer and use it in GitHub Desktop.
Save scottashipp/28eec8431413717662b2 to your computer and use it in GitHub Desktop.
object SuperHeroEscape extends App {
def getFreeFromATrap(doSuperPower: String => Unit, trap: String) = {
println()
println(s"Oh no I'm trapped by ${trap}.")
println(s"I will break free!")
doSuperPower(trap)
}
def flyOut(trap: String) = println(s"I fly out of the ${trap} and into the sky!")
def superStrength(trap: String) = println(s"With my super strength, I can break the ${trap} and escape!")
def laserVision(trap: String) = println(s"My laser vision destroys ${trap} and I escape!")
def invisibility(trap: String) = println(s"Using invisibility I evade the ${trap}!")
getFreeFromATrap(flyOut, "quick sand")
getFreeFromATrap(superStrength, "iron bars")
getFreeFromATrap(laserVision, "a collapsed tunnel")
getFreeFromATrap(invisibility, "armed guards")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment