Ruby Enumerable#some?
Ruby's Enumerable module has #any?, #none?, and #all? We just hit a scenario where we really wanted to know if it had some but not all...
module Enumerable
def some?
self.any? && !self.all?
end
end
Examples:
irb> [1,2,3].some?
=> false
irb> [1,2,nil].some?
=> true
irb> [nil].some?
=> false
irb> [].some?
=> false
Written by Mr Rogers
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#