KillerDesigner
12/2/2013 - 6:57 PM

linkList.rb



class Node
    attr_accessor :data, :next

    def initialize(data=nil)
        @data = data
    end
end

# Without arbitrary args
class List
    attr_accessor :head, :tail
    attr_reader :count

    def initialize
        @head = nil
        @tail = nil
        @count = 0
    end

    def insertFirst(val)
  			new_node = Node.new(val)
        new_node.next = @tail
        @head = val
        @tail = new_node
        @count += 1
    end
end