lib/ruby_algorithms/containers/queue.rb
# If there is something on the queue store the current @first node so we can
# return it at the end then override @first with the next node in the queue,
# @first.next. Finally, check if the first node is nil and if so, set @last to
# be nil.
If there is something on the queue store the current @first node so we can
return it at the end then override @first with the next node in the queue.
If there is something on the queue store the current @first node so we can return it at the end then override @first with the next node in the queue .
def dequeue
   unless @first.nil?
     orig_first = @first
     @first = @first.next
     @last = nil if @first.nil?
     orig_first
   end
  end
def dequeue unless @first . nil? orig_first = @first @first = @first . next @last = nil if @first . nil? orig_first end end
If there is something on the queue store the current @first node so we can
return it at the end then override @first with the next node in the queue,
If there is something on the queue store the current @first node so we can return it at the end then override @first with the next node in the queue
first.next.
Finally, check if the first node is nil and if so, set @last to be nil.
Finally check if the first node is nil and if so set @last to be nil .