Skip to content

Instantly share code, notes, and snippets.

@fronx
Created January 11, 2011 15:52
Show Gist options
  • Select an option

  • Save fronx/774596 to your computer and use it in GitHub Desktop.

Select an option

Save fronx/774596 to your computer and use it in GitHub Desktop.
module Enumerable
def and
inject(true) { |memo, value| memo && value }
end
def or
inject(false) { |memo, value| memo || value }
end
end
[true, false, true].and # => false
[true, false, true].or # => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment