From 00fb59f19ab801b8d7ae44c0d3582e2a31fbbcff Mon Sep 17 00:00:00 2001 From: zzak Date: Thu, 13 Sep 2012 19:08:45 +0000 Subject: * 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 --- array.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'array.c') diff --git a/array.c b/array.c index 273768fbd1..8b2c4c5c8b 100644 --- a/array.c +++ b/array.c @@ -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"] -- cgit v1.2.3