ruby-changes:62810
From: Burdette <ko1@a...>
Date: Thu, 3 Sep 2020 04:02:55 +0900 (JST)
Subject: [ruby-changes:62810] 54fb8fb62a (master): Comply with guide for method doc: array.c (#3506)
https://git.ruby-lang.org/ruby.git/commit/?id=54fb8fb62a From 54fb8fb62a30c7b60ab6443a62821f6f8bc479c4 Mon Sep 17 00:00:00 2001 From: Burdette Lamar <BurdetteLamar@Y...> Date: Wed, 2 Sep 2020 14:02:34 -0500 Subject: Comply with guide for method doc: array.c (#3506) Methods: any? all? one? none? sum shuffle! shuffle sample diff --git a/array.c b/array.c index 2a1a8f5..0373c1e 100644 --- a/array.c +++ b/array.c @@ -1732,7 +1732,7 @@ rb_ary_at(VALUE ary, VALUE pos) https://github.com/ruby/ruby/blob/trunk/array.c#L1732 * a = [:foo, 'bar', 2] * a.first(2) # => [:foo, "bar"] * - * If <tt>n >= ary.size</tt>, returns all elements: + * If <tt>n >= array.size</tt>, returns all elements: * a = [:foo, 'bar', 2] * a.first(50) # => [:foo, "bar", 2] * @@ -1773,7 +1773,7 @@ rb_ary_first(int argc, VALUE *argv, VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L1773 * a = [:foo, 'bar', 2] * a.last(2) # => ["bar", 2] * - * If <tt>n >= ary.size</tt>, returns all elements: + * If <tt>n >= array.size</tt>, returns all elements: * a = [:foo, 'bar', 2] * a.last(50) # => [:foo, "bar", 2] * @@ -2963,7 +2963,7 @@ rb_ary_rotate(VALUE ary, long cnt) https://github.com/ruby/ruby/blob/trunk/array.c#L2963 * a.rotate!(2) * a # => [2, :foo, "bar"] * - * If +count+ is large, uses <tt>count % ary.size</tt> as the count: + * If +count+ is large, uses <tt>count % array.size</tt> as the count: * a = [:foo, 'bar', 2] * a.rotate!(20) * a # => [2, :foo, "bar"] @@ -2979,7 +2979,7 @@ rb_ary_rotate(VALUE ary, long cnt) https://github.com/ruby/ruby/blob/trunk/array.c#L2979 * a.rotate!(-2) * a # => ["bar", 2, :foo] * - * If +count+ is small (far from zero), uses <tt>count % ary.size</tt> as the count: + * If +count+ is small (far from zero), uses <tt>count % array.size</tt> as the count: * a = [:foo, 'bar', 2] * a.rotate!(-5) * a # => ["bar", 2, :foo] @@ -3013,7 +3013,7 @@ rb_ary_rotate_bang(int argc, VALUE *argv, VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L3013 * a1 = a.rotate(2) * a1 # => [2, :foo, "bar"] * - * If +count+ is large, uses <tt>count % ary.size</tt> as the count: + * If +count+ is large, uses <tt>count % array.size</tt> as the count: * a = [:foo, 'bar', 2] * a1 = a.rotate(20) * a1 # => [2, :foo, "bar"] @@ -3029,7 +3029,7 @@ rb_ary_rotate_bang(int argc, VALUE *argv, VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L3029 * a1 = a.rotate(-2) * a1 # => ["bar", 2, :foo] * - * If +count+ is small (far from zero), uses <tt>count % ary.size</tt> as the count: + * If +count+ is small (far from zero), uses <tt>count % array.size</tt> as the count: * a = [:foo, 'bar', 2] * a1 = a.rotate(-5) * a1 # => ["bar", 2, :foo] @@ -4428,18 +4428,18 @@ rb_ary_clear(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L4428 * With arguments +obj+ and \Integer +start+, and no block given, * replaces elements based on the given start. * - * If +start+ is in range (<tt>0 <= start < ary.size</tt>), + * If +start+ is in range (<tt>0 <= start < array.size</tt>), * replaces all elements from offset +start+ through the end: * a = ['a', 'b', 'c', 'd'] * a.fill(:X, 2) # => ["a", "b", :X, :X] * - * If +start+ is too large (<tt>start >= ary.size</tt>), does nothing: + * If +start+ is too large (<tt>start >= array.size</tt>), does nothing: * a = ['a', 'b', 'c', 'd'] * a.fill(:X, 4) # => ["a", "b", "c", "d"] * a = ['a', 'b', 'c', 'd'] * a.fill(:X, 5) # => ["a", "b", "c", "d"] * - * If +start+ is negative, counts from the end (starting index is <tt>start + ary.size</tt>): + * If +start+ is negative, counts from the end (starting index is <tt>start + array.size</tt>): * a = ['a', 'b', 'c', 'd'] * a.fill(:X, -2) # => ["a", "b", :X, :X] * @@ -4460,7 +4460,7 @@ rb_ary_clear(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L4460 * a = ['a', 'b', 'c', 'd'] * a.fill(:X, -2, 1) # => ["a", "b", :X, "d"] * - * If +start+ is large (<tt>start >= ary.size</tt>), extends +self+ with +nil+: + * If +start+ is large (<tt>start >= array.size</tt>), extends +self+ with +nil+: * a = ['a', 'b', 'c', 'd'] * a.fill(:X, 5, 0) # => ["a", "b", "c", "d", nil] * a = ['a', 'b', 'c', 'd'] @@ -4505,12 +4505,12 @@ rb_ary_clear(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L4505 * from offset +start+ to the end; replaces the corresponding element * with the block's return value: * - * If start is in range (<tt>0 <= start < ary.size</tt>), + * If start is in range (<tt>0 <= start < array.size</tt>), * replaces from offset +start+ to the end: * a = ['a', 'b', 'c', 'd'] * a.fill(1) { |index| "new_#{index}" } # => ["a", "new_1", "new_2", "new_3"] * - * If +start+ is too large(<tt>start >= ary.size</tt>), does nothing: + * If +start+ is too large(<tt>start >= array.size</tt>), does nothing: * a = ['a', 'b', 'c', 'd'] * a.fill(4) { |index| fail 'Cannot happen' } # => ["a", "b", "c", "d"] * a = ['a', 'b', 'c', 'd'] @@ -4520,7 +4520,7 @@ rb_ary_clear(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L4520 * a = ['a', 'b', 'c', 'd'] * a.fill(-2) { |index| "new_#{index}" } # => ["a", "b", "new_2", "new_3"] * - * If start is too small (<tt>start <= -ary.size</tt>, replaces all elements: + * If start is too small (<tt>start <= -array.size</tt>, replaces all elements: * a = ['a', 'b', 'c', 'd'] * a.fill(-6) { |index| "new_#{index}" } # => ["new_0", "new_1", "new_2", "new_3"] * a = ['a', 'b', 'c', 'd'] @@ -4538,7 +4538,7 @@ rb_ary_clear(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L4538 * a = ['a', 'b', 'c', 'd'] * a.fill(-2, 1) { |index| "new_#{index}" } # => ["a", "b", "new_2", "d"] * - * If +start+ is large (<tt>start >= ary.size</tt>), extends +self+ with +nil+: + * If +start+ is large (<tt>start >= array.size</tt>), extends +self+ with +nil+: * a = ['a', 'b', 'c', 'd'] * a.fill(5, 0) { |index| "new_#{index}" } # => ["a", "b", "c", "d", nil] * a = ['a', 'b', 'c', 'd'] @@ -5671,7 +5671,7 @@ ary_min_opt_string(VALUE ary, long i, VALUE vmin) https://github.com/ruby/ruby/blob/trunk/array.c#L5671 * array.min -> element * array.min { |a, b| ... } -> element * array.min(n) -> new_array - * ary.min(n) { |a, b| ... } -> new_array + * array.min(n) { |a, b| ... } -> new_array * * Returns one of the following: * - The minimum-valued element from +self+. @@ -6659,7 +6659,7 @@ rb_ary_combination_size(VALUE ary, VALUE args, VALUE eobj) https://github.com/ruby/ruby/blob/trunk/array.c#L6659 /* * call-seq: * array.combination(n) {|element| ... } -> self - * ary.combination(n) -> new_enumerator + * array.combination(n) -> new_enumerator * * Calls the block, if given, with combinations of elements of +self+; * returns +self+. The order of combinations is indeterminate. @@ -7252,8 +7252,6 @@ rb_ary_drop_while(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L7252 * * Returns +true+ if any element of +self+ meets a given criterion. * - * The argument, if given, must have instance method <tt>===</tt>. - * * With no block given and no argument, returns +true+ if +self+ has any truthy element, * +false+ otherwise: * [nil, 0, false].any? # => true @@ -7265,9 +7263,6 @@ rb_ary_drop_while(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L7263 * [0, 1, 2].any? {|element| element > 1 } # => true * [0, 1, 2].any? {|element| element > 2 } # => false * - * Does not call the block if +self+ is empty: - * [].any? {|element| fail 'Cannot happen' } # => false - * * If argument +obj+ is given, returns +true+ if +obj+.<tt>===</tt> any element, * +false+ otherwise: * ['food', 'drink'].any?(/foo/) # => true @@ -7276,17 +7271,7 @@ rb_ary_drop_while(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L7271 * [0, 1, 2].any?(1) # => true * [0, 1, 2].any?(3) # => false * - * Issues a warning ('given block not used') - * if both an argument and a block given: - * [0, 1, 2].any?(/foo/) {|element|} # => false - * - * See also Enumerable#any? - * - * --- - * - * Raises an exception if the argument does not have instance method <tt>===</tt>: - * # Raises NoMethodError (undefined method `===' for #<BasicObject:>): - * [0, 1, 2].any?(BasicObject.new) + * Related: Enumerable#any? */ static VALUE @@ -7325,8 +7310,6 @@ rb_ary_any_p(int argc, VALUE *argv, VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L7310 * * Returns +true+ if all elements of +self+ meet a given criterion. * - * The argument, if given, must have instance method <tt>===</tt>. - * * With no block given and no argument, returns +true+ if +self+ contains only truthy elements, * +false+ otherwise: * [0, 1, :foo].all? # => true @@ -7338,9 +7321,6 @@ rb_ary_any_p(int argc, VALUE *argv, VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L7321 * [0, 1, 2].all? { |element| element < 3 } # => true * [0, 1, 2].all? { |element| element < 2 } # => false * - * Does not call the block if +self+ is empty: - * [].all? { |element| fail 'Cannot happen' } # => true - * * If argument +obj+ is given, returns +true+ if <tt>obj.===</tt> every element, +false+ otherwise: * ['food', 'fool', 'foot'].all?(/foo/) # => true * ['food', 'drink'].all?(/bar/) # => false @@ -7348,18 +7328,7 @@ rb_ary_any_p(int argc, VALUE *argv, VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L7328 * [0, 0, 0].all?(0) # => true * [0, 1, 2].all?(1) # => false * - * Issues a warning ('warning: given block not used') if both an argument and a block given: - * [0, 1, 2].all?(/foo/) { |element|} # => false - * - * See also Enumerable#all? - * - * --- - * - * Raises an exception if the argument (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/