DEV Community 👩‍💻👨‍💻

Discussion on: Linked Lists — BaseCS Video Series

chenge profile image
chenge • Edited on

Your video is great, but where is code sample?

Here is a simple one, only add node.

# create a struct with :value and :next
Cell =, :next)

# create a head of our list
list ="head. hi", nil)

# method which create one more cell and return the struct
def linked_list(value, cell)
  return, cell)

3.times { |i| list = linked_list(i, list) } # O(1)