提交 db2c0d79 编写于 作者: X Xavier Noria

Enumerable#none? is not needed for Ruby >= 1.8.7

上级 329e7f44
......@@ -101,15 +101,6 @@ def many?(&block)
size = block_given? ? select(&block).size : self.size
size > 1
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)
!any?(&block)
end unless [].respond_to?(:none?)
end
class Range #:nodoc:
......
......@@ -89,15 +89,4 @@ def test_many
assert ![ 1, 2 ].many? {|x| x > 1 }
assert [ 1, 2, 2 ].many? {|x| x > 1 }
end
def test_none
assert [].none?
assert [nil, false].none?
assert ![1].none?
assert [].none? {|x| x > 1 }
assert ![ 2 ].none? {|x| x > 1 }
assert ![ 1, 2 ].none? {|x| x > 1 }
assert [ 1, 1 ].none? {|x| x > 1 }
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册