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

ruby-changes:52488

From: mrkn <ko1@a...>
Date: Wed, 12 Sep 2018 17:51:39 +0900 (JST)
Subject: [ruby-changes:52488] mrkn:r64697 (trunk): [DOC] Modify descriptions for ArithmeticSequence

mrkn	2018-09-12 17:51:34 +0900 (Wed, 12 Sep 2018)

  New Revision: 64697

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

  Log:
    [DOC] Modify descriptions for ArithmeticSequence
    
    [ci-skip]

  Modified files:
    trunk/numeric.c
    trunk/range.c
Index: range.c
===================================================================
--- range.c	(revision 64696)
+++ range.c	(revision 64697)
@@ -353,6 +353,7 @@ range_step_size(VALUE range, VALUE args, https://github.com/ruby/ruby/blob/trunk/range.c#L353
  *  call-seq:
  *     rng.step(n=1) {| obj | block }    -> rng
  *     rng.step(n=1)                     -> an_enumerator
+ *     rng.step(n=1)                     -> an_arithmetic_sequence
  *
  *  Iterates over the range, passing each <code>n</code>th element to the block.
  *  If begin and end are numeric, +n+ is added for each iteration.
@@ -360,6 +361,8 @@ range_step_size(VALUE range, VALUE args, https://github.com/ruby/ruby/blob/trunk/range.c#L361
  *  range elements.
  *
  *  If no block is given, an enumerator is returned instead.
+ *  Especially, the enumerator is an Enumerator::ArithmeticSequence
+ *  if begin and end of the range are numeric.
  *
  *    range = Xs.new(1)..Xs.new(10)
  *    range.step(2) {|x| puts x}
Index: numeric.c
===================================================================
--- numeric.c	(revision 64696)
+++ numeric.c	(revision 64697)
@@ -2654,9 +2654,11 @@ num_step_size(VALUE from, VALUE args, VA https://github.com/ruby/ruby/blob/trunk/numeric.c#L2654
 /*
  *  call-seq:
  *     num.step(by: step, to: limit) {|i| block }   ->  self
- *     num.step(by: step, to: limit)		    ->  an_enumerator
+ *     num.step(by: step, to: limit)                ->  an_enumerator
+ *     num.step(by: step, to: limit)                ->  an_arithmetic_sequence
  *     num.step(limit=nil, step=1) {|i| block }     ->  self
  *     num.step(limit=nil, step=1)                  ->  an_enumerator
+ *     num.step(limit=nil, step=1)                  ->  an_arithmetic_sequence
  *
  *  Invokes the given block with the sequence of numbers starting at +num+,
  *  incremented by +step+ (defaulted to +1+) on each call.
@@ -2685,6 +2687,8 @@ num_step_size(VALUE from, VALUE args, VA https://github.com/ruby/ruby/blob/trunk/numeric.c#L2687
  *  and increments itself using the <code>+</code> operator.
  *
  *  If no block is given, an Enumerator is returned instead.
+ *  Especially, the enumerator is an Enumerator::ArithmeticSequence
+ *  if both +limit+ and +step+ are kind of Numeric or <code>nil</code>.
  *
  *  For example:
  *

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

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