From d5b7fc432f0c07dbebb070ef6af17b7d5db6c066 Mon Sep 17 00:00:00 2001 From: eregon Date: Tue, 29 Jan 2013 10:32:27 +0000 Subject: * array.c: Improve documentation about comparison by hash for concerned methods. [ruby-core:51266] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'array.c') diff --git a/array.c b/array.c index f221a614c9..5d91b38884 100644 --- a/array.c +++ b/array.c @@ -3800,7 +3800,7 @@ ary_recycle_hash(VALUE hash) * 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). + * 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 ] * @@ -3832,6 +3832,8 @@ rb_ary_diff(VALUE ary1, VALUE ary2) * Set Intersection --- Returns a new array containing elements common to the * two arrays, excluding any duplicates. * + * It compares elements using their #hash and #eql? methods for efficiency. + * * [ 1, 1, 3, 5 ] & [ 1, 2, 3 ] #=> [ 1, 3 ] * [ 'a', 'b', 'b', 'z' ] & [ 'a', 'b', 'c' ] #=> [ 'a', 'b' ] * @@ -3872,6 +3874,8 @@ rb_ary_and(VALUE ary1, VALUE ary2) * Set Union --- Returns a new array by joining +ary+ with +other_ary+, * excluding any duplicates. * + * It compares elements using their #hash and #eql? methods for efficiency. + * * [ "a", "b", "c" ] | [ "c", "d", "a" ] #=> [ "a", "b", "c", "d" ] * * See also Array#uniq. @@ -3921,6 +3925,8 @@ push_value(st_data_t key, st_data_t val, st_data_t ary) * If a block is given, it will use the return value of the block for * comparison. * + * It compares values using their #hash and #eql? methods for efficiency. + * * Returns +nil+ if no changes are made (that is, no duplicates are found). * * a = [ "a", "a", "b", "b", "c" ] @@ -3983,8 +3989,7 @@ rb_ary_uniq_bang(VALUE ary) * * 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?. + * It compares values using their #hash and #eql? methods for efficiency. * * a = [ "a", "a", "b", "b", "c" ] * a.uniq # => ["a", "b", "c"] -- cgit v1.2.3