[ruby-cvs:71297] mrkn:r64205 (trunk): enumerator.c: Introduce Enumerator::ArithmeticSequence

mrkn at ruby-lang.org mrkn at ruby-lang.org
Mon Aug 6 18:08:29 JST 2018


mrkn	2018-08-06 18:08:28 +0900 (Mon, 06 Aug 2018)

  New Revision: 64205

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

  Log:
    enumerator.c: Introduce Enumerator::ArithmeticSequence
    
    This commit introduces new core class Enumerator::ArithmeticSequence.
    Enumerator::ArithmeticSequence is a subclass of Enumerator, and
    represents a number generator of an arithmetic sequence.
    
    After this commit, Numeric#step and Range#step without blocks
    returned an ArithmeticSequence object instead of an Enumerator.
    
    This class introduces the following incompatibilities:
    
    - You can create a zero-step ArithmeticSequence,
      and its size is not ArgumentError, but Infinity.
    - You can create a negative-step ArithmeticSequence from a range.
    
    [ruby-core:82816] [Feature #13904]

  Added files:
    trunk/test/ruby/test_arithmetic_sequence.rb
  Modified files:
    trunk/enumerator.c
    trunk/internal.h
    trunk/numeric.c
    trunk/range.c
    trunk/spec/ruby/core/numeric/shared/step.rb
    trunk/spec/ruby/core/numeric/step_spec.rb
    trunk/spec/ruby/core/range/step_spec.rb
    trunk/test/ruby/test_enumerator.rb
    trunk/test/ruby/test_numeric.rb
    trunk/test/ruby/test_range.rb


More information about the ruby-cvs mailing list