1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Avoid confusion in Array#- and Array#difference docs (#2070)

My previous attempt to correct #2068 apparently failed and the confusing
wording ("instances") was merged into trunk instead.

This should address any potential confusion.
This commit is contained in:
Olivier Lacan 2019-08-15 11:42:17 -04:00 committed by Takashi Kokubun
parent 7704bbd640
commit 7c46aa6911

12
array.c
View file

@ -4500,15 +4500,15 @@ ary_recycle_hash(VALUE hash)
* Array Difference * Array Difference
* *
* Returns a new array that is a copy of the original array, removing all * Returns a new array that is a copy of the original array, removing all
* instances of any item that also appear in +other_ary+. The order is preserved * occurences of any item that also appear in +other_ary+. The order is
* from the original array. * preserved from the original array.
* *
* It compares elements using their #hash and #eql? methods for efficiency. * It compares elements using their #hash and #eql? methods for efficiency.
* *
* [ 1, 1, 2, 2, 3, 3, 4, 5 ] - [ 1, 2, 4 ] #=> [ 3, 3, 5 ] * [ 1, 1, 2, 2, 3, 3, 4, 5 ] - [ 1, 2, 4 ] #=> [ 3, 3, 5 ]
* *
* Note that while 1 and 2 were only present once in the array argument, and * Note that while 1 and 2 were only present once in the array argument, and
* were present twice in the receiver array, all instances of each Integer are * were present twice in the receiver array, all occurences of each Integer are
* removed in the returned array. * removed in the returned array.
* *
* If you need set-like behavior, see the library class Set. * If you need set-like behavior, see the library class Set.
@ -4551,7 +4551,7 @@ rb_ary_diff(VALUE ary1, VALUE ary2)
* Array Difference * Array Difference
* *
* Returns a new array that is a copy of the original array, removing all * Returns a new array that is a copy of the original array, removing all
* instances of any item that also appear in +other_ary+. The order is * occurences of any item that also appear in +other_ary+. The order is
* preserved from the original array. * preserved from the original array.
* *
* It compares elements using their #hash and #eql? methods for efficiency. * It compares elements using their #hash and #eql? methods for efficiency.
@ -4559,10 +4559,10 @@ rb_ary_diff(VALUE ary1, VALUE ary2)
* [ 1, 1, 2, 2, 3, 3, 4, 5 ].difference([ 1, 2, 4 ]) #=> [ 3, 3, 5 ] * [ 1, 1, 2, 2, 3, 3, 4, 5 ].difference([ 1, 2, 4 ]) #=> [ 3, 3, 5 ]
* *
* Note that while 1 and 2 were only present once in the array argument, and * Note that while 1 and 2 were only present once in the array argument, and
* were present twice in the receiver array, all instances of each Integer are * were present twice in the receiver array, all occurences of each Integer are
* removed in the returned array. * removed in the returned array.
* *
* Multiple array arguments can be supplied and all instances of any element * Multiple array arguments can be supplied and all occurences of any element
* in those supplied arrays that match the receiver will be removed from the * in those supplied arrays that match the receiver will be removed from the
* returned array. * returned array.
* *