* array.c (rb_ary_diff, rb_ary_uniq):

Enhance documentation for array uniqueness
  Based on a patch by Robin Dupret
  [Bug #6872] [ruby-core:47209]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
zzak 2012-09-13 19:08:45 +00:00
parent 1ae1b85e81
commit 00fb59f19a
2 changed files with 29 additions and 5 deletions

View File

@ -1,3 +1,10 @@
Fri Sep 14 04:05:00 2012 Zachary Scott <zzak@ruby-lang.org>
* array.c (rb_ary_diff, rb_ary_uniq):
Enhance documentation for array uniqueness
Based on a patch by Robin Dupret
[Bug #6872] [ruby-core:47209]
Fri Sep 14 03:30:00 2012 Zachary Scott <zzak@ruby-lang.org>
* array.c (rb_ary_select):

27
array.c
View File

@ -3090,6 +3090,8 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary)
* a = [ "a", "b", "c" ]
* a + [ "d", "e", "f" ]
* a #=> [ "a", "b", "c", "d", "e", "f" ]
*
* See also Array#concat.
*/
VALUE
@ -3117,6 +3119,8 @@ rb_ary_plus(VALUE x, VALUE y)
* a = [ 1, 2, 3 ]
* a.concat( [ 4, 5 ] )
* a #=> [ 1, 2, 3, 4, 5 ]
*
* See also Array#+.
*/
VALUE
@ -3518,11 +3522,16 @@ ary_recycle_hash(VALUE hash)
* call-seq:
* ary - other_ary -> new_ary
*
* Array Difference --- Returns a new array that is a copy of the original
* array, removing any items that also appear in +other_ary+. (If you need
* set-like behavior, see the library class Set.)
* Array Difference
*
* Returns a new array that is a copy of the original array, removing any
* items that also appear in +other_ary+.
*
* It compares elements using their hash (returned by the Object#hash method).
*
* [ 1, 1, 2, 2, 3, 3, 4, 5 ] - [ 1, 2, 4 ] #=> [ 3, 3, 5 ]
*
* If you need set-like behavior, see the library class Set.
*/
static VALUE
@ -3552,6 +3561,8 @@ rb_ary_diff(VALUE ary1, VALUE ary2)
*
* [ 1, 1, 3, 5 ] & [ 1, 2, 3 ] #=> [ 1, 3 ]
* [ 'a', 'b', 'b', 'z' ] & [ 'a', 'b', 'c' ] #=> [ 'a', 'b' ]
*
* See also Array#uniq.
*/
@ -3589,6 +3600,8 @@ rb_ary_and(VALUE ary1, VALUE ary2)
* excluding any duplicates.
*
* [ "a", "b", "c" ] | [ "c", "d", "a" ] #=> [ "a", "b", "c", "d" ]
*
* See also Array#uniq.
*/
static VALUE
@ -3693,8 +3706,12 @@ rb_ary_uniq_bang(VALUE ary)
* ary.uniq -> ary or nil
* ary.uniq { |item| ... } -> ary or nil
*
* Returns a new array by removing duplicate values in +self+. If a block
* is given, it will use the return value of the block for comparison.
* Returns a new array by removing duplicate values in +self+.
*
* If a block is given, it will use the return value of the block for comparison.
*
* It compares elements using their hash (provided by the Object#hash method)
* then compares hashes with Object#eql?.
*
* a = [ "a", "a", "b", "b", "c" ]
* a.uniq # => ["a", "b", "c"]