ruby-changes:45959
From: nagachika <ko1@a...>
Date: Mon, 20 Mar 2017 06:45:41 +0900 (JST)
Subject: [ruby-changes:45959] nagachika:r58030 (ruby_2_3): merge revision(s) 57434: [Backport #13161]
nagachika 2017-03-20 06:45:36 +0900 (Mon, 20 Mar 2017) New Revision: 58030 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58030 Log: merge revision(s) 57434: [Backport #13161] Enumerable#{min,min_by,max,max_by} [ci skip] * enum.c: [DOC] Enumerable#{min,min_by,max,max_by} return a sorted array when +n+ argument is used. * enum.c: Small typo : minimum -> maximum [Bug #13161] Author: Eric Duminil <eric.duminil@g...> Modified directories: branches/ruby_2_3/ Modified files: branches/ruby_2_3/enum.c branches/ruby_2_3/version.h Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 58029) +++ ruby_2_3/version.h (revision 58030) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #define RUBY_VERSION "2.3.3" #define RUBY_RELEASE_DATE "2017-03-20" -#define RUBY_PATCHLEVEL 251 +#define RUBY_PATCHLEVEL 252 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_3/enum.c =================================================================== --- ruby_2_3/enum.c (revision 58029) +++ ruby_2_3/enum.c (revision 58030) @@ -1469,11 +1469,12 @@ min_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg https://github.com/ruby/ruby/blob/trunk/ruby_2_3/enum.c#L1469 * 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 @@ -1555,11 +1556,12 @@ max_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg https://github.com/ruby/ruby/blob/trunk/ruby_2_3/enum.c#L1556 * 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 @@ -1772,7 +1774,8 @@ min_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, a https://github.com/ruby/ruby/blob/trunk/ruby_2_3/enum.c#L1774 * 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"] @@ -1831,8 +1834,9 @@ max_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, a https://github.com/ruby/ruby/blob/trunk/ruby_2_3/enum.c#L1834 * 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"] Property changes on: ruby_2_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r57434 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/