module

Talgene::Advanceable(T)

The Talgene::Advanceable module allows types to have a successive.

Including types must provide a #advance method which returns the next term in the series.

require "talgene"

record Integer, value : Int32 do
  include Talgene::Advanceable(Integer)

  def advance : Integer
    Integer.new @value + 1
  end
end

integer = Integer.new(0)
integer.advance # => Integer(@value=1)

Instance methods

advance(count : Int)

Returns the term of this series which is count steps away or self if count is negative or zero.

require "talgene"

record Integer, value : Int32 do
  include Talgene::Advanceable(Integer)

  def advance : Integer
    Integer.new @value + 1
  end
end

integer = Integer.new(0)
integer.advance(10) # => Integer(@value=10)
Source
advance

Must return the next term of this series.

Source