summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-09-13 19:08:45 +0000
committerzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-09-13 19:08:45 +0000
commit00fb59f19ab801b8d7ae44c0d3582e2a31fbbcff (patch)
treebbe03221ec8efd3abcc14cdb2b54382c6e32f1b4
parent1ae1b85e81bcfa1742e7d6fd5d02c0b11f1170ce (diff)
* 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
-rw-r--r--ChangeLog7
-rw-r--r--array.c27
2 files changed, 29 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 0af11e5..377d829 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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):
diff --git a/array.c b/array.c
index 273768f..8b2c4c5 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"]