Added Enumberable#several? to encapsulate collection.size > 1 [DHH]

上级 ed0cb91a
*Edge*
* Added Enumberable#several? to encapsulate collection.size > 1 [DHH]
* Add more standard Hash methods to ActiveSupport::OrderedHash [Steve Purcell]
* Namespace Inflector, Dependencies, OrderedOptions, and TimeZone under ActiveSupport [Josh Peek]
......
......@@ -66,4 +66,9 @@ def index_by
accum
end
end
# Returns true if the collection has more than 1 element. Functionally equivalent to collection.size > 1.
def several?
size > 1
end
end
......@@ -63,4 +63,10 @@ def test_index_by
assert_equal({ 5 => payments[0], 15 => payments[1], 10 => payments[2] },
payments.index_by { |p| p.price })
end
def test_several
assert ![].several?
assert ![ 1 ].several?
assert [ 1, 2 ].several?
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册