lib/ruby_algorithms/containers/queue.rb
# Enqueue a new node by first checking if there is anything on the queue and if
# so, assign a new node to the @last pointer then setting @first to @last.
# Otherwise, we create a new node and point to it from the @last node (via the
# next attribute). Then override @last with @last.next.
Enqueue a new node by first checking if there is anything on the queue and if
so, assign a new node to the @last pointer then setting @first to @last.
Otherwise, we create a new node and point to it from the @last node (via the
next attribute). Then override @last with @last.next.
Enqueue a new node by first checking if there is anything on the queue and if so assign a new node to the @last pointer then setting @first to @last . Otherwise we create a new node and point to it from the @last node ( via the next attribute ) . Then override @last with @last . next .
def enqueue(obj)
   if @first.nil?
     @last = Node.new(obj)
     @first = @last
   else
     @last.next = Node.new(obj)
     @last = @last.next
   end
  end
def enqueue ( obj ) if @first . nil? @last = Node . new ( obj ) @first = @last else @last . next = Node . new ( obj ) @last = @last . next end end
Enqueue a new node by first checking if there is anything on the queue and if
so, assign a new node to the @last pointer then setting @first to @last.
Enqueue a new node by first checking if there is anything on the queue and if so assign a new node to the @last pointer then setting @first to @last .
obj