Skip to content

Instantly share code, notes, and snippets.

@laktek
Created December 11, 2008 00:48
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 laktek/34558 to your computer and use it in GitHub Desktop.
Save laktek/34558 to your computer and use it in GitHub Desktop.
#check if at least one child has content - i.e. given a list of booleans, at least one is true?
inject(false) { |one_child_has_content, child| one_child_has_content || child.has_content? }
#check if all the constraints are true - i.e. given a list of booleans, all of them are true?
@constraints.inject(true) { |accepted, constraint| accepted && constraint.check(result) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment