class Apricot::Cons

Public Class Methods

new(head, tail) click to toggle source
# File lib/apricot/cons.rb, line 5
def initialize(head, tail)
  @head = head
  @tail = tail.to_seq
end

Public Instance Methods

each() { |first| ... } click to toggle source
# File lib/apricot/cons.rb, line 22
def each
  yield first
  @tail.each {|x| yield x }
end
first() click to toggle source
# File lib/apricot/cons.rb, line 10
def first
  @head
end
next() click to toggle source
# File lib/apricot/cons.rb, line 14
def next
  if @tail
    @tail
  else
    nil
  end
end