Method: CircularLinked::List#add

Defined in:
lib/circular_linked/list.rb

#add(value) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/circular_linked/list.rb', line 12

def add(value)
  new_node = Node.new(value, head)
  
  @head ||= new_node
  new_node.next ||= head
  
  last_node.next = new_node
end