The desired behavior of the following code is that when you call findLinkToRemove() on a Node it will recursively find the last node in the chain and remove it. The actual behavior is that nothing happens because
node = nothing
is an assignment not a mutation. Is there a way to make it change the field of the parent node to be nothing instead of just assigning the pointer to nothing [without passing the parent as a parameter which I really really don't want to do]?
mutable struct Node
next::Union{Nothing, Node}
end
function findLinkToRemove(node::Node)
if node.next === nothing
node = nothing
else
findLinkToRemove(node.next)
end
end