I need to write a DoubleLinkedList, checking for LinkedList I saw

add: link after: otherLink

        "Add otherLink  after link in the list. Answer aLink."

        | savedLink |
        lastLink == otherLink ifTrue: [^ self addLast: link].
        savedLink := otherLink nextLink.
        otherLink nextLink: link.
        link nextLink:  savedLink.
        ^link.

Why is savedLink needed ?

Why not:
        lastLink == otherLink ifTrue: [^ self addLast: link].
        link nextLink:  otherLink nextLink.
        otherLink nextLink: link.
        ^link.

Are there any hidden reason I don't see?

-- 
http://blog.ofset.org/hilaire

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to