Skip to content

Instantly share code, notes, and snippets.

@0x0dea
Created June 17, 2015 12:45
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 0x0dea/8120823ed2e9a8f8dab8 to your computer and use it in GitHub Desktop.
Save 0x0dea/8120823ed2e9a8f8dab8 to your computer and use it in GitHub Desktop.
Improved Enumerable#all?
module Enumerable
def all? p = nil
pred = block_given? ? proc : -> x { p ? p === x : x }
each { |obj| return false unless pred[obj] }
true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment