Skip to content

Instantly share code, notes, and snippets.

@mzaks
Created October 21, 2016 13:26
Show Gist options
  • Select an option

  • Save mzaks/d930fb1d2abe7350bf7d57a55d094f3a to your computer and use it in GitHub Desktop.

Select an option

Save mzaks/d930fb1d2abe7350bf7d57a55d094f3a to your computer and use it in GitHub Desktop.
struct HaveYoutriedToTurnItOffAndOnAgain : Action {
func execute(data: String, callback: @escaping (DataType, BehaviourResult) -> ()) {
print("Have you tried to turn it off and on again?")
callback(data, .succeeded)
}
}
struct YesNoQuestion : Action {
func execute(data: String, callback: @escaping (DataType, BehaviourResult) -> ()) {
print("[yes/no]")
if let answer = readLine(), answer == "yes" {
callback(answer, .succeeded)
} else {
callback(data, .failed)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment