class Node ⏎
attr_accessor :data, :next
def initialize(data)
@data = data
@next = nil
end
end
class LinkedList
def initialize
@head = nil
end
def append(data)
new_node = Node.new(data)
if @head.nil?
@head = new_node
else
current = @head
while current.next
current = current.next
end
current.next = new_node
end
end
end