From 1d3e87a28cbd49c8b6abcc011a8c43cc33c275e1 Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Sun, 23 Aug 2020 12:10:01 -0500 Subject: [PATCH] Remove checks for self returned in array.c and hash.c examples (#3446) Further compliance with https://github.com/ruby/ruby/blob/master/doc/method_documentation.rdoc#details-and-examples- --- array.c | 133 ++++++++++++++------------------------------------------ hash.c | 129 ++++++++++++++---------------------------------------- 2 files changed, 65 insertions(+), 197 deletions(-) diff --git a/array.c b/array.c index b159ae70f0..2f14194e43 100644 --- a/array.c +++ b/array.c @@ -658,9 +658,8 @@ ary_ensure_room_for_push(VALUE ary, long add_len) * Freezes +self+; returns +self+: * a = [] * a.frozen? # => false - * a1 = a.freeze + * a.freeze * a.frozen? # => true - * a1.equal?(a) # => true # Returned self * * An attempt to modify a frozen \Array raises an exception: * # Raises FrozenError (can't modify frozen Array: [:foo, "bar", 2]): @@ -1005,8 +1004,6 @@ rb_ary_s_try_convert(VALUE dummy, VALUE ary) * * a = Array.new(3, 'x') * a # => ['x', 'x', 'x'] - * a[1].equal?(a[0]) # => true # Identity check. - * a[2].equal?(a[0]) # => true # Identity check. * * With a block and argument +size+, * returns an \Array of the given size; @@ -1224,9 +1221,7 @@ ary_take_first_or_last(int argc, const VALUE *argv, VALUE ary, enum ary_take_pos * * Appends +object+ to +self+; returns +self+: * a = [:foo, 'bar', 2] - * a1 = a << :baz - * a1 # => [:foo, "bar", 2, :baz] - * a1.equal?(a) # => true # Returned self + * a << :baz # => [:foo, "bar", 2, :baz] * * Appends +object+ as one element, even if it is another \Array: * @@ -1274,9 +1269,7 @@ rb_ary_cat(VALUE ary, const VALUE *argv, long len) * * Appends each argument in +objects+ to +self+; returns +self+: * a = [:foo, 'bar', 2] - * a1 = a.push(:baz, :bat) - * a1 # => [:foo, "bar", 2, :baz, :bat] - * a1.equal?(a) # => true # Returned self + * a.push(:baz, :bat) # => [:foo, "bar", 2, :baz, :bat] * * Appends each argument as one element, even if it is another \Array: * @@ -1615,9 +1608,7 @@ ary_ensure_room_for_unshift(VALUE ary, int argc) * * Prepends the given +objects+ to +self+: * a = [:foo, 'bar', 2] - * a1 = a.unshift(:bam, :bat) - * a1 # => [:bam, :bat, :foo, "bar", 2] - * a1.equal?(a) # => true # Returned self + * a.unshift(:bam, :bat) # => [:bam, :bat, :foo, "bar", 2] */ static VALUE @@ -2473,9 +2464,7 @@ rb_ary_aset(int argc, VALUE *argv, VALUE ary) * When +index+ is non-negative, inserts all given +objects+ * before the element at offset +index+: * a = [:foo, 'bar', 2] - * a1 = a.insert(1, :bat, :bam) - * a # => [:foo, :bat, :bam, "bar", 2] - * a1.object_id == a.object_id # => true + * a.insert(1, :bat, :bam) # => [:foo, :bat, :bam, "bar", 2] * * Extends the array if +index+ is beyond the array (index >= self.size): * a = [:foo, 'bar', 2] @@ -2550,8 +2539,7 @@ ary_enum_length(VALUE ary, VALUE args, VALUE eobj) * When a block given, passes each successive array element to the block; * returns +self+: * a = [:foo, 'bar', 2] - * a1 = a.each {|element| puts "#{element.class} #{element}" } - * a1.equal?(a) # => true # Returned self + * a.each {|element| puts "#{element.class} #{element}" } * * Output: * Symbol foo @@ -2604,8 +2592,7 @@ rb_ary_each(VALUE ary) * When a block given, passes each successive array index to the block; * returns +self+: * a = [:foo, 'bar', 2] - * a1 = a.each_index {|index| puts "#{index} #{a[index]}" } - * a1.equal?(a) # => true # Returned self + * a.each_index {|index| puts "#{index} #{a[index]}" } * * Output: * 0 foo @@ -2658,8 +2645,7 @@ rb_ary_each_index(VALUE ary) * When a block given, passes, in reverse order, each element to the block; * returns +self+: * a = [:foo, 'bar', 2] - * a1 = a.reverse_each {|element| puts "#{element.class} #{element}" } - * a1.equal?(a) # => true # Returned self + * a.reverse_each {|element| puts "#{element.class} #{element}" } * * Output: * Integer 2 @@ -2992,9 +2978,7 @@ rb_ary_to_s(VALUE ary) * * When +self+ is an instance of \Array, returns +self+: * a = [:foo, 'bar', 2] - * a.instance_of?(Array) # => true - * a1 = a.to_a - * a1.equal?(a) # => true # Returned self + * a.to_a # => [:foo, "bar", 2] * * Otherwise, returns a new \Array containing the elements of +self+: * class MyArray < Array; end @@ -3083,8 +3067,7 @@ rb_ary_to_h(VALUE ary) * * Returns +self+: * a = [:foo, 'bar', 2] - * a1 = a.to_ary - * a1.equal?(a) # => true # Returned self + * a.to_ary # => [:foo, "bar", 2] */ static VALUE @@ -3125,9 +3108,7 @@ rb_ary_reverse(VALUE ary) * * Reverses +self+ in place: * a = ['foo', 'bar', 'two'] - * a1 = a.reverse! - * a1 # => ["two", "bar", "foo"] - * a1.equal?(a) # => true # Returned self + * a.reverse! # => ["two", "bar", "foo"] */ static VALUE @@ -3214,9 +3195,7 @@ rb_ary_rotate(VALUE ary, long cnt) * * When no argument given, rotates the first element to the last position: * a = [:foo, 'bar', 2, 'bar'] - * a1 = a.rotate! - * a1 # => ["bar", 2, "bar", :foo] - * a1.equal?(a1) # => true # Retruned self + * a.rotate! # => ["bar", 2, "bar", :foo] * * --- * @@ -3814,9 +3793,7 @@ rb_ary_collect(VALUE ary) * Calls the block, if given, with each element; * replaces the element with the block's return value: * a = [:foo, 'bar', 2] - * a1 = a.collect! { |element| element.class } - * a1 # => [Symbol, String, Integer] - * a1.equal?(a) # => true # Returned self + * a.collect! { |element| element.class } # => [Symbol, String, Integer] * * --- * @@ -4043,9 +4020,7 @@ select_bang_ensure(VALUE a) * * Returns +self+ if any elements were removed: * a = [:foo, 'bar', 2, :bam] - * a1 = a.select! {|element| element.to_s.start_with?('b') } - * a1 # => ["bar", :bam] - * a1.equal?(a) # => true # Returned self + * a.select! {|element| element.to_s.start_with?('b') } # => ["bar", :bam] * * Returns +nil+ if no elements were removed. * @@ -4077,9 +4052,7 @@ rb_ary_select_bang(VALUE ary) * Retains those elements for which the block returns a truthy value; * deletes all other elements; returns +self+: * a = [:foo, 'bar', 2, :bam] - * a1 = a.keep_if {|element| element.to_s.start_with?('b') } - * a1 # => ["bar", :bam] - * a1.equal?(a) # => true # Returned self + * a.keep_if {|element| element.to_s.start_with?('b') } # => ["bar", :bam] * * Returns a new \Enumerator if no block given: * a = [:foo, 'bar', 2, :bam] @@ -4121,9 +4094,8 @@ ary_resize_smaller(VALUE ary, long len) * returns the last deleted element: * s1 = 'bar'; s2 = 'bar' * a = [:foo, s1, 2, s2] - * deleted_obj = a.delete('bar') + * a.delete('bar') # => "bar" * a # => [:foo, 2] - * deleted_obj.equal?(s2) # => true # Returned self * * Returns +nil+ if no elements removed. * @@ -4138,7 +4110,6 @@ ary_resize_smaller(VALUE ary, long len) * a = [:foo, s1, 2, s2] * deleted_obj = a.delete('bar') {|obj| fail 'Cannot happen' } * a # => [:foo, 2] - * deleted_obj.object_id == s2.object_id # => true * * If no such elements are found, returns the block's return value: * a = [:foo, 'bar', 2] @@ -4455,9 +4426,7 @@ ary_reject_bang(VALUE ary) * * Returns +self+ if any elements removed: * a = [:foo, 'bar', 2, 'bat'] - * a1 = a.reject! {|element| element.to_s.start_with?('b') } - * a1 # => [:foo, 2] - * a1.equal?(a) # => true # Returned self + * a.reject! {|element| element.to_s.start_with?('b') } # => [:foo, 2] * * Returns +nil+ if no elements removed. * @@ -4509,9 +4478,7 @@ rb_ary_reject(VALUE ary) * Removes each element in +self+ for which the block returns a truthy value; * returns +self+: * a = [:foo, 'bar', 2, 'bat'] - * a1 = a.delete_if {|element| element.to_s.start_with?('b') } - * a1 # => [:foo, 2] - * a1.equal?(a) # => true # Returned self + * a.delete_if {|element| element.to_s.start_with?('b') } # => [:foo, 2] * * Returns a new \Enumerator if no block given: * a = [:foo, 'bar', 2] @@ -4726,9 +4693,7 @@ rb_ary_transpose(VALUE ary) * * Replaces the content of +self+ with the content of +other_array+: * a = [:foo, 'bar', 2] - * a1 = a.replace(['foo', :bar, 3]) - * a1 # => ["foo", :bar, 3] - * a1.equal?(a) # => true # Returned self + * a.replace(['foo', :bar, 3]) # => ["foo", :bar, 3] * * Ignores the size of +self+: * @@ -4783,8 +4748,7 @@ rb_ary_replace(VALUE copy, VALUE orig) * * Removes all elements from +self+: * a = [:foo, 'bar', 2] - * a1 = a.clear - * a1.equal?(a) # => true # Returned self + * a.clear # => [] */ VALUE @@ -4829,9 +4793,7 @@ rb_ary_clear(VALUE ary) * With argument +obj+ and no block given, replaces all elements with that one object: * a = ['a', 'b', 'c', 'd'] * a # => ["a", "b", "c", "d"] - * a1 = a.fill(:X) - * a1 # => [:X, :X, :X, :X] - * a.equal?(a) # => true # Retrurned self + * a.fill(:X) # => [:X, :X, :X, :X] * * --- * @@ -5115,9 +5077,7 @@ ary_append(VALUE x, VALUE y) * * Adds to +array+ all elements from each array in +other_arrays+; returns +self+: * a = [0, 1] - * a1 = a.concat([2, 3], [4, 5]) - * a1 # => [0, 1, 2, 3, 4, 5] - * a1.equal?(a) # => true # Returned self + * a.concat([2, 3], [4, 5]) # => [0, 1, 2, 3, 4, 5] * * Returns +self+ unmodified if no arguments given: * a = [0, 1] @@ -5659,11 +5619,7 @@ rb_ary_diff(VALUE ary1, VALUE ary2) * [0, 1, 2, 3].difference([3, 0], [1, 3]) # => [2] * [0, 1, 2].difference([4]) # => [0, 1, 2] * - * Returns a copy of +self+ if no arguments given: - * a0 = [0, 1] - * a1 = a0.difference(*[]) - * a1 # => [0, 1] - * a1.equal?(a0) # => false + * Returns a copy of +self+ if no arguments given. * * See also Array#-. */ @@ -5773,11 +5729,7 @@ rb_ary_and(VALUE ary1, VALUE ary2) * Preserves order from +self+: * [0, 1, 2].intersection([2, 1, 0]) # => [0, 1, 2] * - * Returns a copy of +self+ if no arguments given: - * a0 = [0, 1] - * a1 = a0.intersection(*[]) - * a1 # => [0, 1] - * a1.equal?(a0) # => false + * Returns a copy of +self+ if no arguments given. * * See also Array#&. */ @@ -5875,11 +5827,7 @@ rb_ary_or(VALUE ary1, VALUE ary2) * [0, 1, 1].union([2, 1], [3, 1]) # => [0, 1, 2, 3] * [0, 1, 2, 3].union([3, 2], [1, 0]) # => [0, 1, 2, 3] * - * Returns a copy of +self+ if no arguments given: - * a0 = [0, 1] - * a1 = a0.union(*[]) - * a1 # => [0, 1] - * a1.equal?(a0) # => false + * Returns a copy of +self+ if no arguments given. * * See also Array#|. */ @@ -6332,9 +6280,7 @@ push_value(st_data_t key, st_data_t val, st_data_t ary) * * Returns +self+ if any elements removed: * a = [0, 0, 1, 1, 2, 2] - * a1 = a.uniq! - * a1 # => [0, 1, 2] - * a1.equal?(a) # => true # Returned self + * a.uniq! # => [0, 1, 2] * * Returns +nil+ if no elements removed. * @@ -6346,9 +6292,7 @@ push_value(st_data_t key, st_data_t val, st_data_t ary) * * Returns +self+ if any elements removed: * a = ['a', 'aa', 'aaa', 'b', 'bb', 'bbb'] - * a1 = a.uniq! {|element| element.size } - * a1 # => ['a', 'aa', 'aaa'] - * a1.equal?(a) # => true # Returned self + * a.uniq! {|element| element.size } # => ['a', 'aa', 'aaa'] * * Returns +nil+ if no elements removed. */ @@ -6434,12 +6378,7 @@ rb_ary_uniq(VALUE ary) * * Removes all +nil+ elements from +self+. * - * Returns +self+ if any elements removed: - * a = [nil, 0, nil, 1, nil, 2, nil] - * a1 = a.compact! # => [0, 1, 2] - * a1.equal?(a) # => true # Returned self - * - * Returns +nil+ if no elements removed. + * Returns +self+ if any elements removed, otherwise +nil+. */ static VALUE @@ -6640,9 +6579,7 @@ flatten(VALUE ary, int level) * * With non-negative argument +level+, flattens recursively through +level+ levels: * a = [ 0, [ 1, [2, 3], 4 ], 5 ] - * a1 = a.flatten!(1) - * a1 # => [0, 1, [2, 3], 4, 5] - * a1.equal?(a) # => true # Returned self + * a.flatten!(1) # => [0, 1, [2, 3], 4, 5] * a = [ 0, [ 1, [2, 3], 4 ], 5 ] * a.flatten!(2) # => [0, 1, 2, 3, 4, 5] * a = [ 0, [ 1, [2, 3], 4 ], 5 ] @@ -7126,8 +7063,7 @@ rb_ary_permutation_size(VALUE ary, VALUE args, VALUE eobj) * * Example: * a = [0, 1, 2] - * a1 = a.permutation(2) {|permutation| p permutation } - * a1.equal?(a) # => true # Returned self + * a.permutation(2) {|permutation| p permutation } * Output: * [0, 1] * [0, 2] @@ -7269,8 +7205,7 @@ rb_ary_combination_size(VALUE ary, VALUE args, VALUE eobj) * * Example: * a = [0, 1, 2] - * a1 = a.combination(2) {|combination| p combination } - * a1.equal?(a) # => true # Returned self + * a.combination(2) {|combination| p combination } * Output: * [0, 1] * [0, 2] @@ -7406,8 +7341,7 @@ rb_ary_repeated_permutation_size(VALUE ary, VALUE args, VALUE eobj) * * +n+ = 1: * a = [0, 1, 2] - * a1 = a.repeated_permutation(1) {|permutation| p permutation } - * a1.equal?(a) # => true # Returned self + * a.repeated_permutation(1) {|permutation| p permutation } * Output: * [0] * [1] @@ -7535,8 +7469,7 @@ rb_ary_repeated_combination_size(VALUE ary, VALUE args, VALUE eobj) * * +n+ = 1: * a = [0, 1, 2] - * a1 = a.repeated_combination(1) {|combination| p combination } - * a1.equal?(a) # => true # Returned self + * a.repeated_combination(1) {|combination| p combination } * Output: * [0] * [1] diff --git a/hash.c b/hash.c index 76b521cb21..1594e84c97 100644 --- a/hash.c +++ b/hash.c @@ -1946,10 +1946,7 @@ rb_check_hash_type(VALUE hash) * row.respond_to?(:to_hash) # => true * Hash.try_convert(row) # => {"Name"=>"Bob", "Age"=>45} * - * Returns the given obj if it is a Hash: - * h = {} - * h1 = Hash.try_convert(h) - * h1.equal?(h) # => true # Identity check + * Returns the given obj if it is a Hash. * * Returns nil unless obj.respond_to?(:to_hash). * @@ -2600,16 +2597,12 @@ hash_enum_size(VALUE hash, VALUE args, VALUE eobj) * deletes each entry for which the block returns a truthy value; * returns +self+: * h = {foo: 0, bar: 1, baz: 2} - * h1 = h.delete_if { |key, value| value > 0 } - * h1 # => {:foo=>0} - * h1.equal?(h) # => true # Identity check + * h.delete_if { |key, value| value > 0 } # => {:foo=>0} * * If no block given, returns a new \Enumerator: * h = {foo: 0, bar: 1, baz: 2} * e = h.delete_if # => #0, :bar=>1, :baz=>2}:delete_if> - * h1 = e.each { |key, value| value > 0 } - * h1 # => {:foo=>0} - * h1.equal?(h) # => true # Identity check + * e.each { |key, value| value > 0 } # => {:foo=>0} * * ---- * @@ -2638,18 +2631,14 @@ rb_hash_delete_if(VALUE hash) * Returns +self+, whose remaining entries are those * for which the block returns +false+ or +nil+: * h = {foo: 0, bar: 1, baz: 2} - * h1 = h.reject! {|key, value| value < 2 } - * h1 # => {:baz=>2} - * h1.equal?(h) # => true # Identity check + * h.reject! {|key, value| value < 2 } # => {:baz=>2} * * Returns +nil+ if no entries are removed. * * Returns a new \Enumerator if no block given: * h = {foo: 0, bar: 1, baz: 2} * e = h.reject! # => #0, :bar=>1, :baz=>2}:reject!> - * h1 = e.each {|key, value| key.start_with?('b') } - * h1 # => {:foo=>0} - * h1.equal?(h) # => true # Identity check + * e.each {|key, value| key.start_with?('b') } # => {:foo=>0} * * --- * @@ -2725,9 +2714,7 @@ rb_hash_reject(VALUE hash) * * Returns a new \Hash object containing the entries for the given +keys+: * h = {foo: 0, bar: 1, baz: 2} - * h1 = h.slice(:baz, :foo) - * h1 # => {:baz=>2, :foo=>0} - * h1.equal?(h) # => false + * h.slice(:baz, :foo) # => {:baz=>2, :foo=>0} * * The given keys that are not found are ignored: * h = {foo: 0, bar: 1} @@ -2820,9 +2807,7 @@ rb_hash_values_at(int argc, VALUE *argv, VALUE hash) * h = {foo: 0, bar: 1, baz: 2} * h.fetch_values(:baz, :foo) # => [2, 0] * - * Returns a new empty \Array if no arguments given: - * h = {foo: 0, bar: 1, baz: 2} - * h.fetch_values # => [] + * Returns a new empty \Array if no arguments given. * * When a block given, calls the block with each missing key, * treating the block's return value as the value for that key: @@ -2869,16 +2854,12 @@ select_i(VALUE key, VALUE value, VALUE result) * * Returns a new \Hash object whose entries are those for which the block returns a truthy value: * h = {foo: 0, bar: 1, baz: 2} - * h1 = h.select {|key, value| value < 2 } - * h1 # => {:foo=>0, :bar=>1} - * h1.equal?(h) # => false + * h.select {|key, value| value < 2 } # => {:foo=>0, :bar=>1} * * Returns a new \Enumerator if no block given: * h = {foo: 0, bar: 1, baz: 2} * e = h.select # => #0, :bar=>1, :baz=>2}:select> - * h1 = e.each {|key, value| value < 2 } - * h1 # => {:foo=>0, :bar=>1} - * h1.equal?(h) # => false + * e.each {|key, value| value < 2 } # => {:foo=>0, :bar=>1} * * --- * @@ -2921,18 +2902,14 @@ keep_if_i(VALUE key, VALUE value, VALUE hash) * * Returns +self+, whose entries are those for which the block returns a truthy value: * h = {foo: 0, bar: 1, baz: 2} - * h1 = h.select! {|key, value| value < 2 } - * h # => {:foo=>0, :bar=>1} - * h1.equal?(h) # => true + * h.select! {|key, value| value < 2 } => {:foo=>0, :bar=>1} * * Returns +nil+ if no entries were removed. * * Returns a new \Enumerator if no block given: * h = {foo: 0, bar: 1, baz: 2} * e = h.select! # => #0, :bar=>1, :baz=>2}:select!> - * h1 = e.each { |key, value| value < 2 } - * h1 # => {:foo=>0, :bar=>1} - * h1.equal?(h) # => true + * e.each { |key, value| value < 2 } # => {:foo=>0, :bar=>1} * * --- * @@ -2965,16 +2942,12 @@ rb_hash_select_bang(VALUE hash) * retains the entry if the block returns a truthy value; * deletes the entry otherwise; returns +self+. * h = {foo: 0, bar: 1, baz: 2} - * h1 = h.keep_if { |key, value| key.start_with?('b') } - * h1 # => {:bar=>1, :baz=>2} - * h1.object_id == h.object_id # => true + * h.keep_if { |key, value| key.start_with?('b') } # => {:bar=>1, :baz=>2} * * Returns a new \Enumerator if no block given: * h = {foo: 0, bar: 1, baz: 2} * e = h.keep_if # => #0, :bar=>1, :baz=>2}:keep_if> - * h1 = e.each { |key, value| key.start_with?('b') } - * h1 # => {:bar=>1, :baz=>2} - * h1.object_id == h.object_id # => true + * e.each { |key, value| key.start_with?('b') } # => {:bar=>1, :baz=>2} * * Raises an exception if the block attempts to add a new key: * h = {foo: 0, bar: 1, baz: 2} @@ -3005,8 +2978,7 @@ clear_i(VALUE key, VALUE value, VALUE dummy) * * Removes all hash entries; returns +self+: * h = {foo: 0, bar: 1, baz: 2} - * h1 = h.clear # => {} - * h1.equal?(h) # => true # Identity check + * h.clear # => {} */ VALUE @@ -3117,9 +3089,7 @@ rb_hash_aset(VALUE hash, VALUE key, VALUE val) * Replaces the entire contents of +self+ with the contents of +other_hash+; * returns +self+: * h = {foo: 0, bar: 1, baz: 2} - * h1 = h.replace({bat: 3, bam: 4}) - * h1 # => {:bat=>3, :bam=>4} - * h1.equal?(h) # => true # Identity check + * h.replace({bat: 3, bam: 4}) # => {:bat=>3, :bam=>4} */ static VALUE @@ -3213,9 +3183,7 @@ each_value_i(VALUE key, VALUE value, VALUE _) * * Calls the given block with each value; returns +self+: * h = {foo: 0, bar: 1, baz: 2} - * h1 = h.each_value {|value| puts value } - * h1 # => {:foo=>0, :bar=>1, :baz=>2} - * h1.equal?(h) # => true # Identity check + * h.each_value {|value| puts value } # => {:foo=>0, :bar=>1, :baz=>2} * Output: * 0 * 1 @@ -3261,9 +3229,7 @@ each_key_i(VALUE key, VALUE value, VALUE _) * * Calls the given block with each key; returns +self+: * h = {foo: 0, bar: 1, baz: 2} - * h1 = h.each_key {|key| puts key } - * h1 # => {:foo=>0, :bar=>1, :baz=>2} - * h1.equal?(h) # => true # Identity check + * h.each_key {|key| puts key } # => {:foo=>0, :bar=>1, :baz=>2} * Output: * foo * bar @@ -3318,11 +3284,9 @@ each_pair_i_fast(VALUE key, VALUE value, VALUE _) * hash.each -> new_enumerator * hash.each_pair -> new_enumerator * - * Calls the given block with each key-value pair, returning self: + * Calls the given block with each key-value pair, returning +self+: * h = {foo: 0, bar: 1, baz: 2} - * h1 = h.each_pair {|key, value| puts "#{key}: #{value}"} - * h1 # => {:foo=>0, :bar=>1, :baz=>2} - * h1.equal?(h) # => true # Identity check + * h.each_pair {|key, value| puts "#{key}: #{value}"} # => {:foo=>0, :bar=>1, :baz=>2} * Output: * foo: 0 * bar: 1 @@ -3456,9 +3420,7 @@ static VALUE rb_hash_flatten(int argc, VALUE *argv, VALUE hash); * * Returns +self+ with new keys provided by the block: * h = {foo: 0, bar: 1, baz: 2} - * h1 = h.transform_keys! {|key| key.to_s } - * h1 # => {"foo"=>0, "bar"=>1, "baz"=>2} - * h1.equal?(h) # => true # Identity check + * h.transform_keys! {|key| key.to_s } # => {"foo"=>0, "bar"=>1, "baz"=>2} * * Overwrites values for duplicate keys: * h = {foo: 0, bar: 1, baz: 2} @@ -3579,9 +3541,7 @@ rb_hash_transform_values(VALUE hash) * * Returns +self+, whose keys are unchanged, and whose values are determined by the given block. * h = {foo: 0, bar: 1, baz: 2} - * h1 = h.transform_values! {|value| value * 100} - * h1 # => {:foo=>0, :bar=>100, :baz=>200} - * h1.equal?(h) # => true # Identity check + * h.transform_values! {|value| value * 100} # => {:foo=>0, :bar=>100, :baz=>200} * * Allows the block to add a new entry: * h = {foo: 0, bar: 1, baz: 2} @@ -3693,9 +3653,7 @@ rb_hash_inspect(VALUE hash) * * Returns +self+: * h = {foo: 0, bar: 1, baz: 2} - * h1 = h.to_hash - * h1 # => {:foo=>0, :bar=>1, :baz=>2} - * h1.equal?(h) # => true # Identity check + * h.to_hash # => {:foo=>0, :bar=>1, :baz=>2} */ static VALUE rb_hash_to_hash(VALUE hash) @@ -3743,9 +3701,7 @@ rb_hash_to_h_block(VALUE hash) * * For an instance of \Hash, returns +self+: * h = {foo: 0, bar: 1, baz: 2} - * h1 = h.to_h - * h1 # => {:foo=>0, :bar=>1, :baz=>2} - * h1.equal?(h) # => true # Identity check + * h.to_h # => {:foo=>0, :bar=>1, :baz=>2} * * For a subclass of \Hash, returns a new \Hash * containing the content of +self+: @@ -4253,8 +4209,7 @@ rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash) * h = {foo: 0, bar: 1, baz: 2} * h1 = {bat: 3, bar: 4} * h2 = {bam: 5, bat:6} - * h3 = h.merge!(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5} - * h3.equal?(h) # => true # Identity check + * h.merge!(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5} * * --- * @@ -4272,7 +4227,6 @@ rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash) * h2 = {bam: 5, bat:6} * h3 = h.merge!(h1, h2) { |key, old_value, new_value| old_value + new_value } * h3 # => {:foo=>0, :bar=>5, :baz=>2, :bat=>9, :bam=>5} - * h3.equal?(h) # => true # Identity check * * Allows the block to add a new key: * h = {foo: 0, bar: 1, baz: 2} @@ -4280,7 +4234,6 @@ rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash) * h2 = {bam: 5, bat:6} * h3 = h.merge!(h1, h2) { |key, old_value, new_value| h[:new_key] = 10 } * h3 # => {:foo=>0, :bar=>10, :baz=>2, :bat=>10, :new_key=>10, :bam=>5} - * h3.equal?(h) # => true # Identity check * * --- * @@ -4293,7 +4246,6 @@ rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash) * h.merge # => {:foo=>0, :bar=>1, :baz=>2} * h1 = h.merge! { |key, old_value, new_value| raise 'Cannot happen' } * h1 # => {:foo=>0, :bar=>1, :baz=>2} - * h1.equal?(h) # => true # Identity check */ static VALUE @@ -4392,9 +4344,7 @@ rb_hash_update_by(VALUE hash1, VALUE hash2, rb_hash_update_func *func) * h = {foo: 0, bar: 1, baz: 2} * h1 = {bat: 3, bar: 4} * h2 = {bam: 5, bat:6} - * h3 = h.merge(h1, h2) - * h3 # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5} - * h3.equal?(h) # => false # Identity check + * h.merge(h1, h2) # => {:foo=>0, :bar=>4, :baz=>2, :bat=>6, :bam=>5} * * --- * @@ -4412,7 +4362,6 @@ rb_hash_update_by(VALUE hash1, VALUE hash2, rb_hash_update_func *func) * h2 = {bam: 5, bat:6} * h3 = h.merge(h1, h2) { |key, old_value, new_value| old_value + new_value } * h3 # => {:foo=>0, :bar=>5, :baz=>2, :bat=>9, :bam=>5} - * h3.equal?(h) # => false # Identity check * * Ignores an attempt in the block to add a new key: * h = {foo: 0, bar: 1, baz: 2} @@ -4420,7 +4369,6 @@ rb_hash_update_by(VALUE hash1, VALUE hash2, rb_hash_update_func *func) * h2 = {bam: 5, bat:6} * h3 = h.merge(h1, h2) { |key, old_value, new_value| h[:new_key] = 10 } * h3 # => {:foo=>0, :bar=>10, :baz=>2, :bat=>10, :bam=>5} - * h3.equal?(h) # => false # Identity check * * --- * @@ -4430,12 +4378,9 @@ rb_hash_update_by(VALUE hash1, VALUE hash2, rb_hash_update_func *func) * * Example: * h = {foo: 0, bar: 1, baz: 2} - * h1 = h.merge + * h.merge # => {:foo=>0, :bar=>1, :baz=>2} + * h1 = h.merge { |key, old_value, new_value| raise 'Cannot happen' } * h1 # => {:foo=>0, :bar=>1, :baz=>2} - * h1.equal?(h) # => false # Identity check - * h2 = h.merge { |key, old_value, new_value| raise 'Cannot happen' } - * h2 # => {:foo=>0, :bar=>1, :baz=>2} - * h2.equal?(h) # => false # Identity check */ static VALUE @@ -4688,9 +4633,7 @@ rb_hash_compact(VALUE hash) * * Returns +self+ with all its +nil+-valued entries removed (in place): * h = {foo: 0, bar: nil, baz: 2, bat: nil} - * h1 = h.compact! - * h1 # => {:foo=>0, :baz=>2} - * h1.equal?(h) # => true + * h.compact! # => {:foo=>0, :baz=>2} * * Returns +nil+ if no entries were removed. */ @@ -4723,7 +4666,6 @@ static st_table *rb_init_identtable_with_size(st_index_t size); * so +s1+ will overwrite +s0+: * s0 = 'x' * s1 = 'x' - * s0.equal?(s0) # => false * h = {} * h.compare_by_identity? # => false * h[s0] = 0 @@ -4733,8 +4675,7 @@ static st_table *rb_init_identtable_with_size(st_index_t size); * After calling \#compare_by_identity, the keys are considered to be different, * and therefore do not overwrite each other: * h = {} - * h1 = h.compare_by_identity # => {} - * h1.equal?(h) # => true + * h.compare_by_identity # => {} * h.compare_by_identity? # => true * h[s0] = 0 * h[s1] = 1 @@ -5806,9 +5747,7 @@ env_keys(int raw) * The order of the names is OS-dependent. * See {About Ordering}[#class-ENV-label-About+Ordering]. * - * Returns the empty Array if ENV is empty: - * ENV.clear - * ENV.keys # => [] + * Returns the empty Array if ENV is empty. */ static VALUE @@ -5893,9 +5832,7 @@ env_values(void) * The order of the values is OS-dependent. * See {About Ordering}[#class-ENV-label-About+Ordering]. * - * Returns the empty Array if ENV is empty: - * ENV.clear - * ENV.values # => [] + * Returns the empty Array if ENV is empty. */ static VALUE env_f_values(VALUE _) @@ -6072,8 +6009,7 @@ env_delete_if(VALUE ehash) * Returns +nil+ in the Array for each name that is not an ENV name: * ENV.values_at('foo', 'bat', 'bar', 'bam') # => ["0", nil, "1", nil] * - * Returns an empty \Array if no names given: - * ENV.values_at() # => [] + * Returns an empty \Array if no names given. * * Raises an exception if any name is invalid. * See {Invalid Names and Values}[#class-ENV-label-Invalid+Names+and+Values]. @@ -7135,7 +7071,6 @@ env_update(VALUE env, VALUE hash) * h = {s => 0} * first_key = h.keys.first * first_key.frozen? # => true - * first_key.equal?(s) # => false * * ==== User-Defined \Hash Keys *