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

ruby-changes:45849

From: naruse <ko1@a...>
Date: Mon, 13 Mar 2017 01:27:35 +0900 (JST)
Subject: [ruby-changes:45849] naruse:r57924 (ruby_2_4): merge revision(s) 57770:

naruse	2017-03-13 01:27:30 +0900 (Mon, 13 Mar 2017)

  New Revision: 57924

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

  Log:
    merge revision(s) 57770:
    
    enum.c: documentation for Enumerable#sort_by
    
    * enum.c: [DOC] improve structure of docs for Enumerable#sort_by,
      adopt explanation of the comparison block from Array#sort_by,
      drop mention of 1.8, fix typos.

  Modified directories:
    branches/ruby_2_4/
  Modified files:
    branches/ruby_2_4/enum.c
    branches/ruby_2_4/version.h
Index: ruby_2_4/enum.c
===================================================================
--- ruby_2_4/enum.c	(revision 57923)
+++ ruby_2_4/enum.c	(revision 57924)
@@ -926,19 +926,23 @@ enum_first(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_4/enum.c#L926
  *     enum.sort                  -> array
  *     enum.sort { |a, b| block } -> array
  *
- *  Returns an array containing the items in <i>enum</i> sorted,
- *  either according to their own <code><=></code> method, or by using
- *  the results of the supplied block. The block should return -1, 0, or
- *  +1 depending on the comparison between <i>a</i> and <i>b</i>. As of
- *  Ruby 1.8, the method <code>Enumerable#sort_by</code> implements a
- *  built-in Schwartzian Transform, useful when key computation or
- *  comparison is expensive.
+ *  Returns an array containing the items in <i>enum</i> sorted.
+ *
+ *  Comparisons for the sort will be done using the items' own
+ *  <code><=></code> operator or using an optional code block.
+ *
+ *  The block must implement a comparison between +a+ and +b+ and return
+ *  an integer less than 0 when +b+ follows +a+, +0+ when +a+ and +b+
+ *  are equivalent, or an integer greater than 0 when +a+ follows +b+.
  *
  *  The result is not guaranteed as stable.  When comparison of two
  *  elements returns +0+, the order of the elements is unpredictable.
  *
- *     %w(rhea kea flea).sort          #=> ["flea", "kea", "rhea"]
+ *     %w(rhea kea flea).sort           #=> ["flea", "kea", "rhea"]
  *     (1..10).sort { |a, b| b <=> a }  #=> [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
+ *
+ *  See also Enumerable#sort_by. It implements a Schwartzian transform
+ *  which is useful when key computation or comparison is expensive.
  */
 
 static VALUE
@@ -1012,7 +1016,7 @@ sort_by_cmp(const void *ap, const void * https://github.com/ruby/ruby/blob/trunk/ruby_2_4/enum.c#L1016
  *
  *  If no block is given, an enumerator is returned instead.
  *
- *     %w{apple pear fig}.sort_by { |word| word.length}
+ *     %w{apple pear fig}.sort_by { |word| word.length }
  *                   #=> ["fig", "pear", "apple"]
  *
  *  The current implementation of <code>sort_by</code> generates an
@@ -1057,7 +1061,7 @@ sort_by_cmp(const void *ap, const void * https://github.com/ruby/ruby/blob/trunk/ruby_2_4/enum.c#L1061
  *  This still generates many unnecessary <code>Time</code> objects. A
  *  more efficient technique is to cache the sort keys (modification
  *  times in this case) before the sort. Perl users often call this
- *  approach a Schwartzian Transform, after Randal Schwartz. We
+ *  approach a Schwartzian transform, after Randal Schwartz. We
  *  construct a temporary array, where each element is an array
  *  containing our sort key along with the filename. We sort this array,
  *  and then extract the filename from the result.
Index: ruby_2_4/version.h
===================================================================
--- ruby_2_4/version.h	(revision 57923)
+++ ruby_2_4/version.h	(revision 57924)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1
 #define RUBY_VERSION "2.4.0"
 #define RUBY_RELEASE_DATE "2017-03-13"
-#define RUBY_PATCHLEVEL 79
+#define RUBY_PATCHLEVEL 80
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3

Property changes on: ruby_2_4
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57770


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

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