class Hamster::Cons

@private
The last ‘Cons` instance in the chain has the {EmptyList} as its tail.
`Cons`.
each `Cons` holding a single element and a pointer to the next
rest of the list. This way a singly linked list can be constructed, with
the head is an element in the list, and the tail is a reference to the
A Cons, also known as a “cons cell”, has a “head” and a “tail”, where
The basic building block for constructing lists

def cached_size?

def cached_size?
  @size != nil
end

def empty?

def empty?
  false
end

def initialize(head, tail = EmptyList)

def initialize(head, tail = EmptyList)
  @head = head
  @tail = tail
  @size = tail.cached_size? ? tail.size + 1 : nil
end

def size

def size
  @size ||= super
end