зеркало из https://github.com/github/ruby.git
[DOC] Add pound sign before all <=> methods
This commit is contained in:
Родитель
66124cdb17
Коммит
f56be4286f
30
array.c
30
array.c
|
@ -3404,7 +3404,7 @@ sort_2(const void *ap, const void *bp, void *dummy)
|
|||
*
|
||||
* Returns +self+ with its elements sorted in place.
|
||||
*
|
||||
* With no block, compares elements using operator <tt><=></tt>
|
||||
* With no block, compares elements using operator <tt>#<=></tt>
|
||||
* (see Comparable):
|
||||
*
|
||||
* a = 'abcde'.split('').shuffle
|
||||
|
@ -3507,7 +3507,7 @@ rb_ary_sort_bang(VALUE ary)
|
|||
*
|
||||
* Returns a new +Array+ whose elements are those from +self+, sorted.
|
||||
*
|
||||
* With no block, compares elements using operator <tt><=></tt>
|
||||
* With no block, compares elements using operator <tt>#<=></tt>
|
||||
* (see Comparable):
|
||||
*
|
||||
* a = 'abcde'.split('').shuffle
|
||||
|
@ -5932,13 +5932,13 @@ ary_max_opt_string(VALUE ary, long i, VALUE vmax)
|
|||
* with a numeric.
|
||||
*
|
||||
* With no argument and no block, returns the element in +self+
|
||||
* having the maximum value per method <tt><=></tt>:
|
||||
* having the maximum value per method <tt>#<=></tt>:
|
||||
*
|
||||
* [1, 0, 3, 2].max # => 3
|
||||
*
|
||||
* With non-negative numeric argument +n+ and no block,
|
||||
* returns a new array with at most +n+ 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.0) # => [3, 2, 1]
|
||||
|
@ -6103,16 +6103,16 @@ ary_min_opt_string(VALUE ary, long i, VALUE vmin)
|
|||
* - The minimum-valued element from +self+.
|
||||
* - A new +Array+ of minimum-valued elements selected from +self+.
|
||||
*
|
||||
* When no block is given, each element in +self+ must respond to method <tt><=></tt>
|
||||
* When no block is given, each element in +self+ must respond to method <tt>#<=></tt>
|
||||
* with an Integer.
|
||||
*
|
||||
* With no argument and no block, returns the element in +self+
|
||||
* having the minimum value per method <tt><=></tt>:
|
||||
* having the minimum value per method <tt>#<=></tt>:
|
||||
*
|
||||
* [0, 1, 2].min # => 0
|
||||
*
|
||||
* With Integer argument +n+ and no block, returns a new +Array+ with at most +n+ elements,
|
||||
* in ascending order per method <tt><=></tt>:
|
||||
* 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]
|
||||
|
@ -6176,12 +6176,12 @@ rb_ary_min(int argc, VALUE *argv, VALUE ary)
|
|||
* array.minmax {|a, b| ... } -> [min_val, max_val]
|
||||
*
|
||||
* Returns a new 2-element +Array+ containing the minimum and maximum values
|
||||
* from +self+, either per method <tt><=></tt> or per a given block:.
|
||||
* from +self+, either per method <tt>#<=></tt> or per a given block:.
|
||||
*
|
||||
* When no block is given, each element in +self+ must respond to method <tt><=></tt>
|
||||
* When no block is given, each element in +self+ must respond to method <tt>#<=></tt>
|
||||
* with an Integer;
|
||||
* returns a new 2-element +Array+ containing the minimum and maximum values
|
||||
* from +self+, per method <tt><=></tt>:
|
||||
* from +self+, per method <tt>#<=></tt>:
|
||||
*
|
||||
* [0, 1, 2].minmax # => [0, 2]
|
||||
*
|
||||
|
@ -8616,11 +8616,11 @@ rb_ary_deconstruct(VALUE ary)
|
|||
* - #first: Returns one or more leading elements.
|
||||
* - #last: Returns one or more trailing elements.
|
||||
* - #max: Returns one or more maximum-valued elements,
|
||||
* as determined by <tt><=></tt> or a given block.
|
||||
* as determined by <tt>#<=></tt> or a given block.
|
||||
* - #min: Returns one or more minimum-valued elements,
|
||||
* as determined by <tt><=></tt> or a given block.
|
||||
* as determined by <tt>#<=></tt> or a given block.
|
||||
* - #minmax: Returns the minimum-valued and maximum-valued elements,
|
||||
* as determined by <tt><=></tt> or a given block.
|
||||
* as determined by <tt>#<=></tt> or a given block.
|
||||
* - #assoc: Returns the first element that is an array
|
||||
* whose first element <tt>==</tt> a given object.
|
||||
* - #rassoc: Returns the first element that is an array
|
||||
|
@ -8633,7 +8633,7 @@ rb_ary_deconstruct(VALUE ary)
|
|||
* - #take: Returns leading elements as determined by a given index.
|
||||
* - #drop_while: Returns trailing elements as determined by a given block.
|
||||
* - #take_while: Returns leading elements as determined by a given block.
|
||||
* - #sort: Returns all elements in an order determined by <tt><=></tt> or a given block.
|
||||
* - #sort: Returns all elements in an order determined by <tt>#<=></tt> or a given block.
|
||||
* - #reverse: Returns all elements in reverse order.
|
||||
* - #compact: Returns an array containing all non-+nil+ elements.
|
||||
* - #select (aliased as #filter): Returns an array containing elements selected by a given block.
|
||||
|
@ -8663,7 +8663,7 @@ rb_ary_deconstruct(VALUE ary)
|
|||
* - #rotate!: Replaces +self+ with its elements rotated.
|
||||
* - #shuffle!: Replaces +self+ with its elements in random order.
|
||||
* - #sort!: Replaces +self+ with its elements sorted,
|
||||
* as determined by <tt><=></tt> or a given block.
|
||||
* as determined by <tt>#<=></tt> or a given block.
|
||||
* - #sort_by!: Replaces +self+ with its elements sorted, as determined by a given block.
|
||||
*
|
||||
* === Methods for Deleting
|
||||
|
|
2
compar.c
2
compar.c
|
@ -293,7 +293,7 @@ cmp_clamp(int argc, VALUE *argv, VALUE x)
|
|||
*
|
||||
* == What's Here
|
||||
*
|
||||
* \Module \Comparable provides these methods, all of which use method <tt><=></tt>:
|
||||
* \Module \Comparable provides these methods, all of which use method <tt>#<=></tt>:
|
||||
*
|
||||
* - #<: Returns whether +self+ is less than the given object.
|
||||
* - #<=: Returns whether +self+ is less than or equal to the given object.
|
||||
|
|
14
enum.c
14
enum.c
|
@ -1358,7 +1358,7 @@ enum_first(int argc, VALUE *argv, VALUE obj)
|
|||
* The ordering of equal elements is indeterminate and may be unstable.
|
||||
*
|
||||
* With no block given, the sort compares
|
||||
* using the elements' own method <tt><=></tt>:
|
||||
* using the elements' own method <tt>#<=></tt>:
|
||||
*
|
||||
* %w[b c a d].sort # => ["a", "b", "c", "d"]
|
||||
* {foo: 0, bar: 1, baz: 2}.sort # => [[:bar, 1], [:baz, 2], [:foo, 0]]
|
||||
|
@ -2327,7 +2327,7 @@ min_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
|
|||
* The ordering of equal elements is indeterminate and may be unstable.
|
||||
*
|
||||
* With no argument and no block, returns the minimum element,
|
||||
* using the elements' own method <tt><=></tt> for comparison:
|
||||
* using the elements' own method <tt>#<=></tt> for comparison:
|
||||
*
|
||||
* (1..4).min # => 1
|
||||
* (-4..-1).min # => -4
|
||||
|
@ -2449,7 +2449,7 @@ max_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
|
|||
* The ordering of equal elements is indeterminate and may be unstable.
|
||||
*
|
||||
* With no argument and no block, returns the maximum element,
|
||||
* using the elements' own method <tt><=></tt> for comparison:
|
||||
* using the elements' own method <tt>#<=></tt> for comparison:
|
||||
*
|
||||
* (1..4).max # => 4
|
||||
* (-4..-1).max # => -1
|
||||
|
@ -2638,7 +2638,7 @@ minmax_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, _memo))
|
|||
* The ordering of equal elements is indeterminate and may be unstable.
|
||||
*
|
||||
* With no argument and no block, returns the minimum and maximum elements,
|
||||
* using the elements' own method <tt><=></tt> for comparison:
|
||||
* using the elements' own method <tt>#<=></tt> for comparison:
|
||||
*
|
||||
* (1..4).minmax # => [1, 4]
|
||||
* (-4..-1).minmax # => [-4, -1]
|
||||
|
@ -4980,9 +4980,9 @@ enum_compact(VALUE obj)
|
|||
* <i>Minimum and maximum value elements</i>:
|
||||
*
|
||||
* - #min: Returns the elements whose values are smallest among the elements,
|
||||
* as determined by <tt><=></tt> or a given block.
|
||||
* as determined by <tt>#<=></tt> or a given block.
|
||||
* - #max: Returns the elements whose values are largest among the elements,
|
||||
* as determined by <tt><=></tt> or a given block.
|
||||
* as determined by <tt>#<=></tt> or a given block.
|
||||
* - #minmax: Returns a 2-element Array containing the smallest and largest elements.
|
||||
* - #min_by: Returns the smallest element, as determined by the given block.
|
||||
* - #max_by: Returns the largest element, as determined by the given block.
|
||||
|
@ -5015,7 +5015,7 @@ enum_compact(VALUE obj)
|
|||
*
|
||||
* These methods return elements in sorted order:
|
||||
*
|
||||
* - #sort: Returns the elements, sorted by <tt><=></tt> or the given block.
|
||||
* - #sort: Returns the elements, sorted by <tt>#<=></tt> or the given block.
|
||||
* - #sort_by: Returns the elements, sorted by the given block.
|
||||
*
|
||||
* === Methods for Iterating
|
||||
|
|
20
range.c
20
range.c
|
@ -1471,7 +1471,7 @@ range_last(int argc, VALUE *argv, VALUE range)
|
|||
* min(n) {|a, b| ... } -> array
|
||||
*
|
||||
* Returns the minimum value in +self+,
|
||||
* using method <tt><=></tt> or a given block for comparison.
|
||||
* using method <tt>#<=></tt> or a given block for comparison.
|
||||
*
|
||||
* With no argument and no block given,
|
||||
* returns the minimum-valued element of +self+.
|
||||
|
@ -1579,7 +1579,7 @@ range_min(int argc, VALUE *argv, VALUE range)
|
|||
* max(n) {|a, b| ... } -> array
|
||||
*
|
||||
* Returns the maximum value in +self+,
|
||||
* using method <tt><=></tt> or a given block for comparison.
|
||||
* using method <tt>#<=></tt> or a given block for comparison.
|
||||
*
|
||||
* With no argument and no block given,
|
||||
* returns the maximum-valued element of +self+.
|
||||
|
@ -1698,10 +1698,10 @@ range_max(int argc, VALUE *argv, VALUE range)
|
|||
* minmax {|a, b| ... } -> [object, object]
|
||||
*
|
||||
* Returns a 2-element array containing the minimum and maximum value in +self+,
|
||||
* either according to comparison method <tt><=></tt> or a given block.
|
||||
* either according to comparison method <tt>#<=></tt> or a given block.
|
||||
*
|
||||
* With no block given, returns the minimum and maximum values,
|
||||
* using <tt><=></tt> for comparison:
|
||||
* using <tt>#<=></tt> for comparison:
|
||||
*
|
||||
* (1..4).minmax # => [1, 4]
|
||||
* (1...4).minmax # => [1, 3]
|
||||
|
@ -2151,7 +2151,7 @@ static int r_cover_range_p(VALUE range, VALUE beg, VALUE end, VALUE val);
|
|||
* Returns +false+ if either:
|
||||
*
|
||||
* - The begin value of +self+ is larger than its end value.
|
||||
* - An internal call to <tt><=></tt> returns +nil+;
|
||||
* - An internal call to <tt>#<=></tt> returns +nil+;
|
||||
* that is, the operands are not comparable.
|
||||
*
|
||||
* Beginless ranges cover all values of the same type before the end,
|
||||
|
@ -2399,7 +2399,7 @@ empty_region_p(VALUE beg, VALUE end, int excl)
|
|||
*
|
||||
* (1..3).overlap?(1) # TypeError
|
||||
*
|
||||
* Returns +false+ if an internal call to <tt><=></tt> returns +nil+;
|
||||
* Returns +false+ if an internal call to <tt>#<=></tt> returns +nil+;
|
||||
* that is, the operands are not comparable.
|
||||
*
|
||||
* (1..3).overlap?('a'..'d') # => false
|
||||
|
@ -2589,7 +2589,7 @@ range_overlap(VALUE range, VALUE other)
|
|||
* == Ranges and Other Classes
|
||||
*
|
||||
* An object may be put into a range if its class implements
|
||||
* instance method <tt><=></tt>.
|
||||
* instance method <tt>#<=></tt>.
|
||||
* Ruby core classes that do so include Array, Complex, File::Stat,
|
||||
* Float, Integer, Kernel, Module, Numeric, Rational, String, Symbol, and Time.
|
||||
*
|
||||
|
@ -2621,15 +2621,15 @@ range_overlap(VALUE range, VALUE other)
|
|||
* == Ranges and User-Defined Classes
|
||||
*
|
||||
* A user-defined class that is to be used in a range
|
||||
* must implement instance <tt><=></tt>;
|
||||
* must implement instance <tt>#<=></tt>;
|
||||
* see Integer#<=>.
|
||||
* To make iteration available, it must also implement
|
||||
* instance method +succ+; see Integer#succ.
|
||||
*
|
||||
* The class below implements both <tt><=></tt> and +succ+,
|
||||
* The class below implements both <tt>#<=></tt> and +succ+,
|
||||
* and so can be used both to construct ranges and to iterate over them.
|
||||
* Note that the Comparable module is included
|
||||
* so the <tt>==</tt> method is defined in terms of <tt><=></tt>.
|
||||
* so the <tt>==</tt> method is defined in terms of <tt>#<=></tt>.
|
||||
*
|
||||
* # Represent a string of 'X' characters.
|
||||
* class Xs
|
||||
|
|
Загрузка…
Ссылка в новой задаче