Move `Array#difference` just after `Array#-`.

parent 67ea80b2
...@@ -88,6 +88,22 @@ class Array ...@@ -88,6 +88,22 @@ class Array
array array
end end
##
# 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: # call-seq:
# ary | other_ary -> new_ary # ary | other_ary -> new_ary
...@@ -124,22 +140,6 @@ class Array ...@@ -124,22 +140,6 @@ class Array
ary ary
end end
##
# 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: # call-seq:
# ary & other_ary -> new_ary # ary & other_ary -> new_ary
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment