summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-19 21:45:36 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-19 21:45:36 +0000
commitb334883cc1543a21970574e8ad7d0d8f3879f8a9 (patch)
tree81fcc6eb6426513f5e457753e6446f9bea031fbd
parentce6fdd55bd0e892f75760bb50aec29dd063dfcea (diff)
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@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@58030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--enum.c14
-rw-r--r--version.h2
2 files changed, 10 insertions, 6 deletions
diff --git a/enum.c b/enum.c
index 9ce5e6084e..c59071588d 100644
--- a/enum.c
+++ b/enum.c
@@ -1469,11 +1469,12 @@ min_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
* 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, args))
* 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, args))
* 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, args))
* 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"]
diff --git a/version.h b/version.h
index 4bd01f6133..3cde90279c 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#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