diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2015-03-02 08:46:20 -0800 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2015-03-02 08:46:29 -0800 |
commit | 521318333eaa2654b9ad535c592281ae9efb9113 (patch) | |
tree | 6cb51453487ceed01d529ae23367afffb1bcfc21 /activesupport/lib | |
parent | 3f4964299acd1351a519293991b97dd78b775073 (diff) | |
download | rails-521318333eaa2654b9ad535c592281ae9efb9113.tar.gz rails-521318333eaa2654b9ad535c592281ae9efb9113.tar.bz2 rails-521318333eaa2654b9ad535c592281ae9efb9113.zip |
Move Array#without from Grouping to Access concern and add dedicated test (relates to #19157)
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/array/access.rb | 12 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/array/grouping.rb | 12 |
2 files changed, 12 insertions, 12 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/access.rb b/activesupport/lib/active_support/core_ext/array/access.rb index ca66d806ef..3177d8498e 100644 --- a/activesupport/lib/active_support/core_ext/array/access.rb +++ b/activesupport/lib/active_support/core_ext/array/access.rb @@ -27,6 +27,18 @@ class Array end end + # Returns a copy of the Array without the specified elements. + # + # people = ["David", "Rafael", "Aaron", "Todd"] + # people.without "Aaron", "Todd" + # => ["David", "Rafael"] + # + # Note: This is an optimization of `Enumerable#without` that uses `Array#-` + # instead of `Array#reject` for performance reasons. + def without(*elements) + self - elements + end + # Equal to <tt>self[1]</tt>. # # %w( a b c d e ).second # => "b" diff --git a/activesupport/lib/active_support/core_ext/array/grouping.rb b/activesupport/lib/active_support/core_ext/array/grouping.rb index b3ada47880..87ae052eb0 100644 --- a/activesupport/lib/active_support/core_ext/array/grouping.rb +++ b/activesupport/lib/active_support/core_ext/array/grouping.rb @@ -113,16 +113,4 @@ class Array results end end - - # Returns a copy of the Array without the specified elements. - # - # people = ["David", "Rafael", "Aaron", "Todd"] - # people.without "Aaron", "Todd" - # => ["David", "Rafael"] - # - # Note: This is an optimization of `Enumerable#without` that uses `Array#-` - # instead of `Array#reject` for performance reasons. - def without(*elements) - self - elements - end end |