[前][次][番号順一覧][スレッド一覧]

ruby-changes:24913

From: zzak <ko1@a...>
Date: Fri, 14 Sep 2012 04:09:02 +0900 (JST)
Subject: [ruby-changes:24913] zzak:r36965 (trunk): * array.c (rb_ary_diff, rb_ary_uniq):

zzak	2012-09-14 04:08:45 +0900 (Fri, 14 Sep 2012)

  New Revision: 36965

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36965

  Log:
    * 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]

  Modified files:
    trunk/ChangeLog
    trunk/array.c

Index: array.c
===================================================================
--- array.c	(revision 36964)
+++ array.c	(revision 36965)
@@ -3090,6 +3090,8 @@
  *     a = [ "a", "b", "c" ]
  *     a + [ "d", "e", "f" ]
  *     a                         #=> [ "a", "b", "c", "d", "e", "f" ]
+ *
+ *  See also Array#concat.
  */
 
 VALUE
@@ -3117,6 +3119,8 @@
  *     a = [ 1, 2, 3 ]
  *     a.concat( [ 4, 5 ] )
  *     a                                 #=> [ 1, 2, 3, 4, 5 ]
+ *
+ *  See also Array#+.
  */
 
 VALUE
@@ -3518,11 +3522,16 @@
  *  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 @@
  *
  *     [ 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 @@
  *  excluding any duplicates.
  *
  *     [ "a", "b", "c" ] | [ "c", "d", "a" ]    #=> [ "a", "b", "c", "d" ]
+ *
+ *  See also Array#uniq.
  */
 
 static VALUE
@@ -3693,9 +3706,13 @@
  *     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"]
  *
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36964)
+++ ChangeLog	(revision 36965)
@@ -1,3 +1,10 @@
+Fri Sep 14 04:05:00 2012  Zachary Scott  <zzak@r...>
+
+	* 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@r...>
 
 	* array.c (rb_ary_select):

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]