Method: Linked::List#shift
- Defined in:
- lib/linked/list.rb
#shift ⇒ Listable?
Shift the first item off the list.
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/linked/list.rb', line 114 def shift return nil if empty? if list_head.last? @_chain.tap { @_chain = nil } else old_head = list_head @_chain = list_head.next old_head.delete end end |