Skip to content

Instantly share code, notes, and snippets.

@sommestad
Last active August 29, 2015 14:02
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 sommestad/3a65d7a8470cf6995274 to your computer and use it in GitHub Desktop.
Save sommestad/3a65d7a8470cf6995274 to your computer and use it in GitHub Desktop.
The Five Whys.
/**
* The Five Whys.
* @see http://en.wikipedia.org/wiki/5_Whys
* @param {Object} person Whodat?
* @param {Object} thing What I'm thinking of doing.
*/
function isItTheRightThingToDo(person, thing) {
for (var i = 0; i < 5; i++) {
if (person.hasActualAnswer(thing)) {
return true;
}
}
return false;
}
@dbrockman
Copy link

protocol Thing {
}

protocol Person {
  func hasActualAnswer(Thing) -> Bool
}

func isItTheRightThingToDo(person: Person, thing: Thing) -> Bool {
  for _ in 0..5 {
    if (person.hasActualAnswer(thing)) {
      return true
    }
  }
  return false
}

@sommestad
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment