Group Group Group Group Group Group Group Group Group

Why is guard tail !== node else going into the scope

In the LinkedList section, when you are inserting a node at the tail you have the case

    guard tail !== node else {
        append(value) //add to end of the list by calling append func
        return
    }

what does !== mean? From what I understand it says that it’s checking if both memory addresses are identical. When going through the implementation through the debugger, the memory address for tail and node are the same so I don’t understand why it’s going sinde the scope block?

!== is true if the two variables reference different objects with different addresses.

A guard statement is sort of the opposite of an if statement - it does nothing if the condition is true, and does the else block if it is false.

This guard statement will execute the block if the condition is false, which means the two variables reference the same object at the same address.

The human speech version might be “Check that these two variables reference different objects, and execute this block if they are not different.”