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

ruby-changes:62689

From: Burdette <ko1@a...>
Date: Mon, 24 Aug 2020 02:10:18 +0900 (JST)
Subject: [ruby-changes:62689] 1d3e87a28c (master): Remove checks for self returned in array.c and hash.c examples (#3446)

https://git.ruby-lang.org/ruby.git/commit/?id=1d3e87a28c

From 1d3e87a28cbd49c8b6abcc011a8c43cc33c275e1 Mon Sep 17 00:00:00 2001
From: Burdette Lamar <BurdetteLamar@Y...>
Date: Sun, 23 Aug 2020 12:10:01 -0500
Subject: 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-

diff --git a/array.c b/array.c
index b159ae7..2f14194 100644
--- a/array.c
+++ b/array.c
@@ -658,9 +658,8 @@ ary_ensure_room_for_push(VALUE ary, long add_len) https://github.com/ruby/ruby/blob/trunk/array.c#L658
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L1004
  *
  *    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 https://github.com/ruby/ruby/blob/trunk/array.c#L1221
  *
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L1269
  *
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L1608
  *
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L2464
  *  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 (<tt>index >= self.size</tt>):
  *    a = [:foo, 'bar', 2]
@@ -2550,8 +2539,7 @@ ary_enum_length(VALUE ary, VALUE args, VALUE eobj) https://github.com/ruby/ruby/blob/trunk/array.c#L2539
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L2592
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L2645
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L2978
  *
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L3067
  *
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L3108
  *
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L3195
  *
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L3793
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L4020
  *
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L4052
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L4094
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L4110
  *    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) https://github.com/ruby/ruby/blob/trunk/array.c#L4426
  *
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L4478
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L4693
  *
  *  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) https://github.com/ruby/ruby/blob/trunk/array.c#L4748
  *
  *  Removes all elements from +self+:
  *    a = [:foo, 'bar', 2]
- *    a1 = a.clear
- *    a1.equal?(a) # => true # Returned self
+ *    a.clear # => []
  (... truncated)

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

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