[前][次][番号順一覧][スレッド一覧]

ruby-changes:46041

From: usa <ko1@a...>
Date: Sun, 26 Mar 2017 02:36:37 +0900 (JST)
Subject: [ruby-changes:46041] usa:r58112 (ruby_2_2): merge revision(s) 57434: [Backport #13161]

usa	2017-03-26 02:36:34 +0900 (Sun, 26 Mar 2017)

  New Revision: 58112

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58112

  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_2/
  Modified files:
    branches/ruby_2_2/enum.c
    branches/ruby_2_2/version.h
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 58111)
+++ ruby_2_2/version.h	(revision 58112)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.7"
 #define RUBY_RELEASE_DATE "2017-03-26"
-#define RUBY_PATCHLEVEL 444
+#define RUBY_PATCHLEVEL 445
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_2/enum.c
===================================================================
--- ruby_2_2/enum.c	(revision 58111)
+++ ruby_2_2/enum.c	(revision 58112)
@@ -1424,11 +1424,12 @@ min_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg https://github.com/ruby/ruby/blob/trunk/ruby_2_2/enum.c#L1424
  *     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
@@ -1510,11 +1511,12 @@ max_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg https://github.com/ruby/ruby/blob/trunk/ruby_2_2/enum.c#L1511
  *     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
@@ -1729,7 +1731,8 @@ min_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, a https://github.com/ruby/ruby/blob/trunk/ruby_2_2/enum.c#L1731
  *     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"]
@@ -1788,8 +1791,9 @@ max_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, a https://github.com/ruby/ruby/blob/trunk/ruby_2_2/enum.c#L1791
  *     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_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57434


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]