Project

General

Profile

Bug #13161 ยป 0001-DOC-Enumerable-min-min_by-max-max_by.patch

Documentation Patch - eric_duminil (Eric Duminil), 01/26/2017 09:10 PM

View differences:

enum.c
* a.min { |a, b| a.length <=> b.length } #=> "dog"
*
* If the +n+ argument is given, minimum +n+ elements are returned
* as an array.
* as a sorted array.
*
* a = %w[albatross dog horse]
* a.min(2) #=> ["albatross", "dog"]
* a.min(2) {|a, b| a.length <=> b.length } #=> ["dog", "horse"]
* [5, 1, 3, 4, 2].min(3) #=> [1, 2, 3]
*/
static VALUE
......
* a.max { |a, b| a.length <=> b.length } #=> "albatross"
*
* If the +n+ argument is given, maximum +n+ elements are returned
* as an array.
* as an array, sorted in descending order.
*
* a = %w[albatross dog horse]
* a.max(2) #=> ["horse", "dog"]
* a.max(2) {|a, b| a.length <=> b.length } #=> ["albatross", "horse"]
* [5, 1, 3, 4, 2].max(3) #=> [5, 4, 3]
*/
static VALUE
......
* a.min_by { |x| x.length } #=> "dog"
*
* If the +n+ argument is given, minimum +n+ elements are returned
* as an array.
* as an array. These +n+ elements are sorted by the value from the
* given block.
*
* a = %w[albatross dog horse]
* p a.min_by(2) {|x| x.length } #=> ["dog", "horse"]
......
* a = %w(albatross dog horse)
* a.max_by { |x| x.length } #=> "albatross"
*
* If the +n+ argument is given, minimum +n+ elements are returned
* as an array.
* If the +n+ argument is given, maximum +n+ elements are returned
* as an array. These +n+ elements are sorted by the value from the
* given block, in descending order.
*
* a = %w[albatross dog horse]
* a.max_by(2) {|x| x.length } #=> ["albatross", "horse"]
    (1-1/1)