Skip to content
Browse files

Add Enumerable#exclude? to bring parity to Enumerable#include? and av…

…oid if !x.include?/else calls [DHH]
  • Loading branch information...
1 parent 1d9468b commit fda3ac6e6824d494102e8fc5f4114a550caa22b1 @dhh dhh committed Dec 14, 2009
View
7 activesupport/CHANGELOG
@@ -1,7 +1,14 @@
+*Edge*
+
+* Add Enumerable#exclude? to bring parity to Enumerable#include? and avoid if !x.include?/else calls [DHH]
+
+
*2.3.5 (November 25, 2009)*
* Minor Bug Fixes and deprecation warnings
+* Update Edinburgh TimeZone to use "Europe/London" instead of "Europe/Dublin" #3310 [Phil Ross]
+
* Fixes for the Nokogiri backend for XmlMini
* Ruby 1.9 Compatibility
View
9 activesupport/lib/active_support/core_ext/enumerable.rb
@@ -102,6 +102,15 @@ def many?(&block)
size = block_given? ? select(&block).size : self.size
size > 1
end
+<<<<<<< HEAD
+=======
+
+ # The negative of the Enumerable#include?. Returns true if the collection does not include the object.
+ def exclude?(object)
+ !include?(object)
+ end
+end
+>>>>>>> 7b61541... Add Enumerable#exclude? to bring parity to Enumerable#include? and avoid if !x.include?/else calls [DHH]
# Returns true if none of the elements match the given block.
#
View
7 activesupport/test/core_ext/enumerable_test.rb
@@ -83,6 +83,7 @@ def test_many
assert ![ 1, 2 ].many? {|x| x > 1 }
assert [ 1, 2, 2 ].many? {|x| x > 1 }
end
+<<<<<<< HEAD
def test_none
assert [].none?
@@ -93,5 +94,11 @@ def test_none
assert ![ 2 ].none? {|x| x > 1 }
assert ![ 1, 2 ].none? {|x| x > 1 }
assert [ 1, 1 ].none? {|x| x > 1 }
+=======
+
+ def test_exclude?
+ assert [ 1 ].exclude?(2)
+ assert ![ 1 ].exclude?(1)
+>>>>>>> 7b61541... Add Enumerable#exclude? to bring parity to Enumerable#include? and avoid if !x.include?/else calls [DHH]
end
end

0 comments on commit fda3ac6

Please sign in to comment.
Something went wrong with that request. Please try again.