public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Added Enumberable#several? to encapsulate collection.size > 1 [DHH]
dhh (author)
Thu Jun 12 15:46:15 -0700 2008
commit  556204abaf95f7c995576cb1358f13de406682ab
tree    a84387ac04af8377b25c4c283a522dc82639bb53
parent  ed0cb91a830f317e3a8192a90294c1005f6156c2
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *Edge*
0
 
0
+* Added Enumberable#several? to encapsulate collection.size > 1 [DHH]
0
+
0
 * Add more standard Hash methods to ActiveSupport::OrderedHash [Steve Purcell]
0
 
0
 * Namespace Inflector, Dependencies, OrderedOptions, and TimeZone under ActiveSupport [Josh Peek]
...
66
67
68
 
 
 
 
 
69
...
66
67
68
69
70
71
72
73
74
0
@@ -66,4 +66,9 @@ module Enumerable
0
       accum
0
     end
0
   end
0
+  
0
+  # Returns true if the collection has more than 1 element. Functionally equivalent to collection.size > 1.
0
+  def several?
0
+    size > 1
0
+  end
0
 end
...
63
64
65
 
 
 
 
 
 
66
...
63
64
65
66
67
68
69
70
71
72
0
@@ -63,4 +63,10 @@ class EnumerableTests < Test::Unit::TestCase
0
     assert_equal({ 5 => payments[0], 15 => payments[1], 10 => payments[2] },
0
                  payments.index_by { |p| p.price })
0
   end
0
+  
0
+  def test_several
0
+    assert ![].several?
0
+    assert ![ 1 ].several?
0
+    assert [ 1, 2 ].several?
0
+  end
0
 end

Comments