#linked list;

1 messages · Page 1 of 1 (latest)

broken tusk
#

your node is nullable, and you are trying to directly access it, you need to unwrap the null value

fallen forge
broken tusk
fallen forge
fallen forge
# broken tusk https://ziglearn.org/chapter-1/#optionals

pub fn remove(self: *Self, item: T) !T {
var curr = self.head;
while (curr) |node| : (curr = node.next) {
var nextNode = node.next.?;
if (nextNode.item == item) {
const value = nextNode.item;
node.next = nextNode.next;
self.allocator.destroy(nextNode);
return value;
}
}
return ItemNotFoundErr.DoesNotExist;
}
i made it ;-;! thank you ❤️