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

ruby-changes:62680

From: Burdette <ko1@a...>
Date: Sat, 22 Aug 2020 05:51:14 +0900 (JST)
Subject: [ruby-changes:62680] ea4ccc0992 (master): Remove trivial examples from array.c (#3442)

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

From ea4ccc09923c56783df8789b0813f7fee7a560c6 Mon Sep 17 00:00:00 2001
From: Burdette Lamar <BurdetteLamar@Y...>
Date: Fri, 21 Aug 2020 15:50:56 -0500
Subject: Remove trivial examples from array.c (#3442)

"Trivial" typically means "returns a new empty Array."

diff --git a/array.c b/array.c
index 5b44c82..b159ae7 100644
--- a/array.c
+++ b/array.c
@@ -658,7 +658,7 @@ 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 # => []
+ *    a1 = a.freeze
  *    a.frozen? # => true
  *    a1.equal?(a) # => true # Returned self
  *
@@ -983,10 +983,7 @@ rb_ary_s_try_convert(VALUE dummy, VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L983
  *
  *  ---
  *
- *  With no block and no arguments, returns a new empty \Array object:
- *
- *    a = Array.new
- *    a # => []
+ *  With no block and no arguments, returns a new empty \Array object.
  *
  *  With no block and a single argument +array+,
  *  returns a new \Array formed from +array+:
@@ -999,8 +996,6 @@ rb_ary_s_try_convert(VALUE dummy, VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L996
  *  returns a new \Array of the given size
  *  whose elements are all +nil+:
  *
- *    a = Array.new(0)
- *    a # => []
  *    a = Array.new(3)
  *    a # => [nil, nil, nil]
  *
@@ -1023,12 +1018,7 @@ rb_ary_s_try_convert(VALUE dummy, VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L1018
  *
  *  With a block and no argument,
  *  or a single argument +0+,
- *  ignores the block and returns a new empty \Array:
- *
- *    a = Array.new(0) { |n| raise 'Cannot happen' }
- *    a # => []
- *    a = Array.new { |n| raise 'Cannot happen' }
- *    a # => []
+ *  ignores the block and returns a new empty \Array.
  *
  *  With a block and arguments +size+ and +default_value+,
  *  gives a warning message
@@ -1348,23 +1338,14 @@ rb_ary_pop(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L1338
  *  ---
  *
  *  When argument +n+ is given and is non-negative and in range,
- *
  *  removes and returns the last +n+ elements in a new \Array:
- *
  *    a = [:foo, 'bar', 2]
- *    a1 = a.pop(2)
- *    a1 # => ["bar", 2]
- *    a # => [:foo]
- *    a.pop(0) # => []
+ *    a.pop(2) # => ["bar", 2]
  *
  *  If +n+ is positive and out of range,
  *  removes and returns all elements:
- *
  *    a = [:foo, 'bar', 2]
- *    a1 = a.pop(50)
- *    a1 # => [:foo, "bar", 2]
- *    a # => []
- *    a.pop(1) # => []
+ *    a.pop(50) # => [:foo, "bar", 2]
  *
  *  ---
  *
@@ -1460,12 +1441,8 @@ rb_ary_shift(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L1441
  *  removes all elements; returns those elements in a new \Array:
  *    a = [:foo, 'bar', 2]
  *    a.shift(3) # => [:foo, 'bar', 2]
- *    a # => []
  *
- *  If +n+ is zero, returns a new empty \Array; +self+ is unmodified:
- *    a = [:foo, 'bar', 2]
- *    a.shift(0) # => []
- *    a # => [:foo, 'bar', 2]
+ *  If +n+ is zero, returns a new empty \Array; +self+ is unmodified.
  *
  *  ---
  *
@@ -1749,10 +1726,7 @@ static VALUE rb_ary_aref2(VALUE ary, VALUE b, VALUE e); https://github.com/ruby/ruby/blob/trunk/array.c#L1726
  *    a[2, 2] # => [2]
  *
  *  If <tt>start == self.size</tt> and <tt>length >= 0</tt>,
- *  returns a new empty \Array:
- *    a = [:foo, 'bar', 2]
- *    a[a.size, 0] # => []
- *    a[a.size, 50] # => []
+ *  returns a new empty \Array.
  *
  *  If +length+ is negative, returns +nil+.
  *
@@ -1765,19 +1739,13 @@ static VALUE rb_ary_aref2(VALUE ary, VALUE b, VALUE e); https://github.com/ruby/ruby/blob/trunk/array.c#L1739
  *    a[0..1] # => [:foo, "bar"]
  *    a[1..2] # => ["bar", 2]
  *
- *  Special case: If <tt>range.start == a.size</tt>, returns a new empty \Array:
- *    a = [:foo, 'bar', 2]
- *    a[a.size..0] # => []
- *    a[a.size..50] # => []
- *    a[a.size..-1] # => []
- *    a[a.size..-50] # => []
+ *  Special case: If <tt>range.start == a.size</tt>, returns a new empty \Array.
  *
  *  If <tt>range.end</tt> is negative, calculates the end index from the end:
  *    a = [:foo, 'bar', 2]
  *    a[0..-1] # => [:foo, "bar", 2]
  *    a[0..-2] # => [:foo, "bar"]
  *    a[0..-3] # => [:foo]
- *    a[0..-4] # => []
  *
  *  If <tt>range.start</tt> is negative, calculates the start index from the end:
  *    a = [:foo, 'bar', 2]
@@ -2593,7 +2561,6 @@ ary_enum_length(VALUE ary, VALUE args, VALUE eobj) https://github.com/ruby/ruby/blob/trunk/array.c#L2561
  *  Allows the array to be modified during iteration:
  *    a = [:foo, 'bar', 2]
  *    a.each {|element| puts element; a.clear if element.to_s.start_with?('b') }
- *    a # => []
  *
  *  Output:
  *    foo
@@ -2648,7 +2615,6 @@ rb_ary_each(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L2615
  *  Allows the array to be modified during iteration:
  *    a = [:foo, 'bar', 2]
  *    a.each_index {|index| puts index; a.clear if index > 0 }
- *    a # => []
  *
  *  Output:
  *    0
@@ -2703,7 +2669,6 @@ rb_ary_each_index(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L2669
  *  Allows the array to be modified during iteration:
  *    a = [:foo, 'bar', 2]
  *    a.reverse_each {|element| puts element; a.clear if element.to_s.start_with?('b') }
- *    a # => []
  *
  *  Output:
  *    2
@@ -3951,8 +3916,7 @@ append_values_at_single(VALUE result, VALUE ary, long olen, VALUE idx) https://github.com/ruby/ruby/blob/trunk/array.c#L3916
  *    a = [:foo, 'bar', 2]
  *    a.values_at(0, 3, 1, 3) # => [:foo, nil, "bar", nil]
  *
- *  Returns a new empty \Array if no arguments given:
- *    [].values_at # => []
+ *  Returns a new empty \Array if no arguments given.
  *
  *  ---
  *
@@ -4364,11 +4328,7 @@ ary_slice_bang_by_rb_ary_splice(VALUE ary, long pos, long len) https://github.com/ruby/ruby/blob/trunk/array.c#L4328
  *    a # => [:foo]
  *
  *  If <tt>start == a.size</tt> and +length+ is non-negative,
- *  returns a new empty \Array:
- *    a = [:foo, 'bar', 2]
- *    a.slice!(a.size, 0) # => []
- *    a.slice!(a.size, 50) # => []
- *    a # => [:foo, "bar", 2]
+ *  returns a new empty \Array.
  *
  *  If +length+ is negative, returns +nil+.
  *
@@ -4380,13 +4340,7 @@ ary_slice_bang_by_rb_ary_splice(VALUE ary, long pos, long len) https://github.com/ruby/ruby/blob/trunk/array.c#L4340
  *     a.slice!(1..2) # => ["bar", 2]
  *    a # => [:foo]
  *
- *  If <tt>range.start == a.size</tt>, returns a new empty \Array:
- *    a = [:foo, 'bar', 2]
- *    a.slice!(a.size..0) # => []
- *    a.slice!(a.size..50) # => []
- *    a.slice!(a.size..-1) # => []
- *    a.slice!(a.size..-50) # => []
- *    a # => [:foo, "bar", 2]
+ *  If <tt>range.start == a.size</tt>, returns a new empty \Array.
  *
  *  If <tt>range.start</tt> is larger than the array size, returns +nil+.
  *
@@ -4779,7 +4733,6 @@ rb_ary_transpose(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L4733
  *  Ignores the size of +self+:
  *
  *    a = [:foo, 'bar', 2]
- *    a.replace([]) # => []
  *    a.replace([:foo, 'bar', 2]) # => [:foo, "bar", 2]
  */
 
@@ -4831,7 +4784,6 @@ rb_ary_replace(VALUE copy, VALUE orig) https://github.com/ruby/ruby/blob/trunk/array.c#L4784
  *  Removes all elements from +self+:
  *    a = [:foo, 'bar', 2]
  *    a1 = a.clear
- *    a1 # => []
  *    a1.equal?(a) # => true # Returned self
  */
 
@@ -5213,7 +5165,6 @@ rb_ary_concat(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/array.c#L5165
  *  When argument +n+ is given, returns a new array built by concatenating the +int+ copies of +self+:
  *    a = ['x', 'y']
  *    a * 3 # => ["x", "y", "x", "y", "x", "y"]
- *    a * 0 # => []
  *
  *  ---
  *
@@ -6078,7 +6029,6 @@ ary_max_opt_string(VALUE ary, long i, VALUE vmax) https://github.com/ruby/ruby/blob/trunk/array.c#L6029
  *  in descending order per method <tt><=></tt>:
  *    [0, 1, 2, 3].max(3) # => [3, 2, 1]
  *    [0, 1, 2, 3].max(6) # => [3, 2, 1]
- *    [0, 1, 2, 3].max(0) # => []
  *
  *  ---
  *
@@ -6091,7 +6041,6 @@ ary_max_opt_string(VALUE ary, long i, VALUE vmax) https://github.com/ruby/ruby/blob/trunk/array.c#L6041
  *  With an argument +n+ and a block, returns a new \Array with at most +n+ elements,
  *  in descending order per the block:
  *    ['0', '00', '000'].max(2) {|a, b| a.size <=> b.size } # => ["000", "00"]
- *    ['0', '00', '000'].max(0) {|a, b| a.size <=> b.size } # => []
  *
  *  ---
  *
@@ -6259,7 +6208,6 @@ ary_min_opt_string(VALUE ary, long i, VALUE vmin) https://github.com/ruby/ruby/blob/trunk/array.c#L6208
  *  in ascending order per method <tt><=></tt>:
  *    [0, 1, 2, 3].min(3) # => [0, 1, 2]
  *    [0, 1, 2, 3].min(6) # => [0, 1, 2, 3]
- *    [0, 1, 2, 3].min(0) # => []
  *
  *  ---
  *
@@ -6273,7 +6221,6 @@ ary_min_opt_string(VALUE ary, long i, VALUE vmin) https://github.com/ruby/ruby/blob/trunk/array.c#L6221
  *  in ascending order per the block:
  *    [0, 1, 2, 3].min(3) # => [0, 1, 2]
  *    [0, 1, 2, 3].min(6) # => [0, 1, 2, 3]
- *    [0, 1, 2, 3].min(0) # => []
  *
  *  ---
  *
@@ -7690,8 +7637,7 @@ rb_ary_repeated_combination(VALUE ary, VALUE num) https://github.com/ruby/ruby/blob/trunk/array.c#L7637
  *    p.size # => 12 # a.size * a1.size * a2.size
  *    p # => [[0, 3, 5], [0, 3, 6], [0, 4, 5], [0, 4, 6], [1, 3, 5], [1, 3, 6], [1, 4, 5], [1, 4, 6], [2, 3, 5], [2, 3, 6], [2, 4, 5], [2, 4, 6]]
  *
- *  If any argument is an empty \Array, returns an empty \Array:
- *    a.product(a1, a2, []) # => []
+ *  If any argument is an empty \Array, returns an empty \Array.
  *
  *  If no argument is given, returns an \Array of 1-element Arrays,
  *  each containing an element of +self+:
@@ -7820,7 +7766,6 @@ done: https://github.com/ruby/ruby/blob/trunk/array.c#L7766
  *
  *  Examples:
  *    a = [0, 1, 2, 3, 4, 5]
- *    a.take(0) # => []
  *    a.take(1) # => [0]
  *    a.take(2) # => [0, 1]
  *    a.take(50) # => [0, 1, 2, 3, 4, 5]
@@ -7857,7 +7802,6 @@ rb_ary_take(VALUE obj, VALUE n) https://github.com/ruby/ (... truncated)

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

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