class Enumerator::ArithmeticSequence
Enumerator::ArithmeticSequence is a subclass of Enumerator, that is a representation of sequences of numbers with common difference. Instances of this class can be generated by the Range#step and Numeric#step methods.
The class can be used for slicing Array (see Array#slice) or custom collections.
Public Instance Methods
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/enumerator/arithmetic_sequence.rbs, line 16
def begin: () -> Numeric?
Returns the number that defines the first element of this arithmetic sequence.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/enumerator/arithmetic_sequence.rbs, line 32
def each: () ?{ (Numeric) -> void } -> self
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/enumerator/arithmetic_sequence.rbs, line 24
def end: () -> Numeric?
Returns the number that defines the end of this arithmetic sequence.
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/enumerator/arithmetic_sequence.rbs, line 40
def exclude_end?: () -> bool
Returns true if this arithmetic sequence excludes its end value.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/enumerator/arithmetic_sequence.rbs, line 50
def last: () -> Numeric?
| (Integer n) -> Array[Numeric]
Returns the last number in this arithmetic sequence, or an array of the last n elements.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/core/enumerator/arithmetic_sequence.rbs, line 60
def size: () -> (Integer | Float)
Returns the number of elements in this arithmetic sequence if it is a finite sequence. Otherwise, returns nil.