summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-10-12 12:39:04 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2019-10-14 17:04:19 +0900
commit682406a38425fd6389a67580e524b9c5c15c25fb (patch)
treece912ceb034f79261ddacbd180676fdec2decec8
parent67ea80b2bd2df64bbfefd0ba8f74f6eeb52074aa (diff)
downloadmruby-682406a38425fd6389a67580e524b9c5c15c25fb.tar.gz
mruby-682406a38425fd6389a67580e524b9c5c15c25fb.zip
Move `Array#difference` just after `Array#-`.
-rw-r--r--mrbgems/mruby-array-ext/mrblib/array.rb32
1 files changed, 16 insertions, 16 deletions
diff --git a/mrbgems/mruby-array-ext/mrblib/array.rb b/mrbgems/mruby-array-ext/mrblib/array.rb
index d4a72a927..fa3db3a70 100644
--- a/mrbgems/mruby-array-ext/mrblib/array.rb
+++ b/mrbgems/mruby-array-ext/mrblib/array.rb
@@ -90,6 +90,22 @@ class Array
##
# call-seq:
+ # ary.difference(other_ary1, other_ary2, ...) -> new_ary
+ #
+ # Returns a new array that is a copy of the original array, removing all
+ # occurrences of any item that also appear in +other_ary+. The order is
+ # preserved from the original array.
+ #
+ def difference(*args)
+ ary = self
+ args.each do |x|
+ ary = ary - x
+ end
+ ary
+ end
+
+ ##
+ # call-seq:
# ary | other_ary -> new_ary
#
# Set Union---Returns a new array by joining this array with
@@ -126,22 +142,6 @@ class Array
##
# call-seq:
- # ary.difference(other_ary1, other_ary2, ...) -> new_ary
- #
- # Returns a new array that is a copy of the original array, removing all
- # occurrences of any item that also appear in +other_ary+. The order is
- # preserved from the original array.
- #
- def difference(*args)
- ary = self
- args.each do |x|
- ary = ary - x
- end
- ary
- end
-
- ##
- # call-seq:
# ary & other_ary -> new_ary
#
# Set Intersection---Returns a new array