Permalink
Browse files

Enumerable#none? conforms to Ruby 1.8.7 behavior

  • Loading branch information...
1 parent 5b7d07f commit 7ee9addb6edc6d231ab5d95a24964a56b0b175d0 @jeremy jeremy committed Nov 19, 2008
@@ -106,11 +106,11 @@ def many?(&block)
end
# Returns true if none of the elements match the given block.
- #
+ #
# success = responses.none? {|r| r.status / 100 == 5 }
#
+ # This is a builtin method in Ruby 1.8.7 and later.
def none?(&block)
- return true if !block_given? || blank?
!any?(&block)
- end
+ end unless [].respond_to?(:none?)
end
@@ -82,7 +82,8 @@ def test_many
def test_none
assert [].none?
- assert [ 1 ].none?
+ assert [nil, false].none?
+ assert ![1].none?
assert [].none? {|x| x > 1 }
assert ![ 2 ].none? {|x| x > 1 }

0 comments on commit 7ee9add

Please sign in to comment.