[DOC] Change arg names from n to count (#12288)
This commit is contained in:
parent
86cf18e01e
commit
50a67820fb
Notes:
git
2024-12-17 15:56:02 +00:00
Merged-By: peterzhu2118 <peter@peterzhu.ca>
54
array.c
54
array.c
@ -5973,9 +5973,9 @@ ary_max_opt_string(VALUE ary, long i, VALUE vmax)
|
|||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* max -> element
|
* max -> element
|
||||||
* max(n) -> new_array
|
* max(count) -> new_array
|
||||||
* max {|a, b| ... } -> element
|
* max {|a, b| ... } -> element
|
||||||
* max(n) {|a, b| ... } -> new_array
|
* max(count) {|a, b| ... } -> new_array
|
||||||
*
|
*
|
||||||
* Returns one of the following:
|
* Returns one of the following:
|
||||||
*
|
*
|
||||||
@ -5992,8 +5992,8 @@ ary_max_opt_string(VALUE ary, long i, VALUE vmax)
|
|||||||
*
|
*
|
||||||
* [1, 0, 3, 2].max # => 3
|
* [1, 0, 3, 2].max # => 3
|
||||||
*
|
*
|
||||||
* With non-negative numeric argument +n+ and no block,
|
* With non-negative numeric argument +count+ and no block,
|
||||||
* returns a new array with at most +n+ elements,
|
* returns a new array with at most +count+ elements,
|
||||||
* in descending order, per method <tt>#<=></tt>:
|
* in descending order, per method <tt>#<=></tt>:
|
||||||
*
|
*
|
||||||
* [1, 0, 3, 2].max(3) # => [3, 2, 1]
|
* [1, 0, 3, 2].max(3) # => [3, 2, 1]
|
||||||
@ -6009,8 +6009,8 @@ ary_max_opt_string(VALUE ary, long i, VALUE vmax)
|
|||||||
* ['0', '', '000', '00'].max {|a, b| a.size <=> b.size }
|
* ['0', '', '000', '00'].max {|a, b| a.size <=> b.size }
|
||||||
* # => "000"
|
* # => "000"
|
||||||
*
|
*
|
||||||
* With non-negative numeric argument +n+ and a block,
|
* With non-negative numeric argument +count+ and a block,
|
||||||
* returns a new array with at most +n+ elements,
|
* returns a new array with at most +count+ elements,
|
||||||
* in descending order, per the block:
|
* in descending order, per the block:
|
||||||
*
|
*
|
||||||
* ['0', '', '000', '00'].max(2) {|a, b| a.size <=> b.size }
|
* ['0', '', '000', '00'].max(2) {|a, b| a.size <=> b.size }
|
||||||
@ -6150,9 +6150,9 @@ ary_min_opt_string(VALUE ary, long i, VALUE vmin)
|
|||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* min -> element
|
* min -> element
|
||||||
* min(n) -> new_array
|
* min(count) -> new_array
|
||||||
* min {|a, b| ... } -> element
|
* min {|a, b| ... } -> element
|
||||||
* min(n) {|a, b| ... } -> new_array
|
* min(count) {|a, b| ... } -> new_array
|
||||||
*
|
*
|
||||||
* Returns one of the following:
|
* Returns one of the following:
|
||||||
*
|
*
|
||||||
@ -6169,8 +6169,8 @@ ary_min_opt_string(VALUE ary, long i, VALUE vmin)
|
|||||||
*
|
*
|
||||||
* [1, 0, 3, 2].min # => 0
|
* [1, 0, 3, 2].min # => 0
|
||||||
*
|
*
|
||||||
* With non-negative numeric argument +n+ and no block,
|
* With non-negative numeric argument +count+ and no block,
|
||||||
* returns a new array with at most +n+ elements,
|
* returns a new array with at most +count+ elements,
|
||||||
* in ascending order, per method <tt>#<=></tt>:
|
* in ascending order, per method <tt>#<=></tt>:
|
||||||
*
|
*
|
||||||
* [1, 0, 3, 2].min(3) # => [0, 1, 2]
|
* [1, 0, 3, 2].min(3) # => [0, 1, 2]
|
||||||
@ -6186,8 +6186,8 @@ ary_min_opt_string(VALUE ary, long i, VALUE vmin)
|
|||||||
* ['0', '', '000', '00'].min {|a, b| a.size <=> b.size }
|
* ['0', '', '000', '00'].min {|a, b| a.size <=> b.size }
|
||||||
* # => ""
|
* # => ""
|
||||||
*
|
*
|
||||||
* With non-negative numeric argument +n+ and a block,
|
* With non-negative numeric argument +count+ and a block,
|
||||||
* returns a new array with at most +n+ elements,
|
* returns a new array with at most +count+ elements,
|
||||||
* in ascending order, per the block:
|
* in ascending order, per the block:
|
||||||
*
|
*
|
||||||
* ['0', '', '000', '00'].min(2) {|a, b| a.size <=> b.size }
|
* ['0', '', '000', '00'].min(2) {|a, b| a.size <=> b.size }
|
||||||
@ -7063,14 +7063,14 @@ rb_ary_permutation_size(VALUE ary, VALUE args, VALUE eobj)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* permutation(n = self.size) {|permutation| ... } -> self
|
* permutation(count = self.size) {|permutation| ... } -> self
|
||||||
* permutation(n = self.size) -> new_enumerator
|
* permutation(count = self.size) -> new_enumerator
|
||||||
*
|
*
|
||||||
* Iterates over permutations of the elements of +self+;
|
* Iterates over permutations of the elements of +self+;
|
||||||
* the order of permutations is indeterminate.
|
* the order of permutations is indeterminate.
|
||||||
*
|
*
|
||||||
* With a block and an in-range positive integer argument +n+ (<tt>0 < n <= self.size</tt>) given,
|
* With a block and an in-range positive integer argument +count+ (<tt>0 < count <= self.size</tt>) given,
|
||||||
* calls the block with each +n+-tuple permutations of +self+;
|
* calls the block with each permutation of +self+ of size +count+;
|
||||||
* returns +self+:
|
* returns +self+:
|
||||||
*
|
*
|
||||||
* a = [0, 1, 2]
|
* a = [0, 1, 2]
|
||||||
@ -7086,13 +7086,13 @@ rb_ary_permutation_size(VALUE ary, VALUE args, VALUE eobj)
|
|||||||
* a.permutation(3) {|perm| perms.push(perm) }
|
* a.permutation(3) {|perm| perms.push(perm) }
|
||||||
* perms # => [[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]]
|
* perms # => [[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]]
|
||||||
*
|
*
|
||||||
* When +n+ is zero, calls the block once with a new empty array:
|
* When +count+ is zero, calls the block once with a new empty array:
|
||||||
*
|
*
|
||||||
* perms = []
|
* perms = []
|
||||||
* a.permutation(0) {|perm| perms.push(perm) }
|
* a.permutation(0) {|perm| perms.push(perm) }
|
||||||
* perms # => [[]]
|
* perms # => [[]]
|
||||||
*
|
*
|
||||||
* When +n+ is out of range (negative or larger than <tt>self.size</tt>),
|
* When +count+ is out of range (negative or larger than <tt>self.size</tt>),
|
||||||
* does not call the block:
|
* does not call the block:
|
||||||
*
|
*
|
||||||
* a.permutation(-1) {|permutation| fail 'Cannot happen' }
|
* a.permutation(-1) {|permutation| fail 'Cannot happen' }
|
||||||
@ -7173,13 +7173,13 @@ rb_ary_combination_size(VALUE ary, VALUE args, VALUE eobj)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* combination(n) {|element| ... } -> self
|
* combination(count) {|element| ... } -> self
|
||||||
* combination(n) -> new_enumerator
|
* combination(count) -> new_enumerator
|
||||||
*
|
*
|
||||||
* When a block and a positive
|
* When a block and a positive
|
||||||
* {integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects]
|
* {integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects]
|
||||||
* argument +n+ (<tt>0 < n <= self.size</tt>)
|
* argument +count+ (<tt>0 < count <= self.size</tt>)
|
||||||
* are given, calls the block with all +n+-tuple combinations of +self+;
|
* are given, calls the block with each combination of +self+ of size +count+;
|
||||||
* returns +self+:
|
* returns +self+:
|
||||||
*
|
*
|
||||||
* a = %w[a b c] # => ["a", "b", "c"]
|
* a = %w[a b c] # => ["a", "b", "c"]
|
||||||
@ -7193,7 +7193,7 @@ rb_ary_combination_size(VALUE ary, VALUE args, VALUE eobj)
|
|||||||
*
|
*
|
||||||
* The order of the yielded combinations is not guaranteed.
|
* The order of the yielded combinations is not guaranteed.
|
||||||
*
|
*
|
||||||
* When +n+ is zero, calls the block once with a new empty array:
|
* When +count+ is zero, calls the block once with a new empty array:
|
||||||
*
|
*
|
||||||
* a.combination(0) {|combination| p combination }
|
* a.combination(0) {|combination| p combination }
|
||||||
* [].combination(0) {|combination| p combination }
|
* [].combination(0) {|combination| p combination }
|
||||||
@ -7203,7 +7203,7 @@ rb_ary_combination_size(VALUE ary, VALUE args, VALUE eobj)
|
|||||||
* []
|
* []
|
||||||
* []
|
* []
|
||||||
*
|
*
|
||||||
* When +n+ is negative or larger than +self.size+ and +self+ is non-empty,
|
* When +count+ is negative or larger than +self.size+ and +self+ is non-empty,
|
||||||
* does not call the block:
|
* does not call the block:
|
||||||
*
|
*
|
||||||
* a.combination(-1) {|combination| fail 'Cannot happen' } # => ["a", "b", "c"]
|
* a.combination(-1) {|combination| fail 'Cannot happen' } # => ["a", "b", "c"]
|
||||||
@ -7680,10 +7680,10 @@ rb_ary_take_while(VALUE ary)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* drop(n) -> new_array
|
* drop(count) -> new_array
|
||||||
*
|
*
|
||||||
* Returns a new array containing all but the first +n+ element of +self+,
|
* Returns a new array containing all but the first +count+ element of +self+,
|
||||||
* where +n+ is a non-negative Integer;
|
* where +count+ is a non-negative integer;
|
||||||
* does not modify +self+.
|
* does not modify +self+.
|
||||||
*
|
*
|
||||||
* Examples:
|
* Examples:
|
||||||
|
9
array.rb
9
array.rb
@ -140,8 +140,8 @@ class Array
|
|||||||
end
|
end
|
||||||
|
|
||||||
# call-seq:
|
# call-seq:
|
||||||
# last -> last_object or nil
|
# last -> last_object or nil
|
||||||
# last(n) -> new_array
|
# last(count) -> new_array
|
||||||
#
|
#
|
||||||
# Returns elements from +self+, or +nil+; +self+ is not modified.
|
# Returns elements from +self+, or +nil+; +self+ is not modified.
|
||||||
#
|
#
|
||||||
@ -152,8 +152,9 @@ class Array
|
|||||||
# a # => [:foo, "bar", 2]
|
# a # => [:foo, "bar", 2]
|
||||||
# [].last # => nil
|
# [].last # => nil
|
||||||
#
|
#
|
||||||
# With a non-negative integer argument +n+ given,
|
#
|
||||||
# returns a new array containing the trailing +n+ elements of +self+, as available:
|
# With non-negative integer argument +count+ given,
|
||||||
|
# returns a new array containing the trailing +count+ elements of +self+, as available:
|
||||||
#
|
#
|
||||||
# a = [:foo, 'bar', 2]
|
# a = [:foo, 'bar', 2]
|
||||||
# a.last(2) # => ["bar", 2]
|
# a.last(2) # => ["bar", 2]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user