DoubleLinkedList: pop

toying-with-ramdb
Philippe PITTOLI 2024-05-26 00:49:38 +02:00
parent a536c5b731
commit 42b18e7ea8
1 changed files with 3 additions and 2 deletions

View File

@ -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