module Talgene::Advanceable(T)

Overview

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)

Direct including types

Defined in:

modules/advanceable.cr

Instance Method Summary

Instance Method Detail

def 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)

[View source]
abstract def advance : T #

Must return the next term of this series.


[View source]