DoubleLinkedList: pop
This commit is contained in:
parent
a536c5b731
commit
42b18e7ea8
@ -243,7 +243,7 @@ class DoubleLinkedList(V)
|
||||
if current = @first
|
||||
@first = nil
|
||||
@last = nil
|
||||
return current.value
|
||||
return current
|
||||
else
|
||||
raise BrokenList.new "pop a list of 1 element but 'first' is nil"
|
||||
end
|
||||
@ -251,7 +251,8 @@ class DoubleLinkedList(V)
|
||||
|
||||
if last = @last
|
||||
@last = last.previous
|
||||
last.value
|
||||
@last.not_nil!.next = nil
|
||||
last
|
||||
else
|
||||
raise BrokenList.new "'last' element is nil despite size > 0"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user