title: Why should I use optional chaining again after checking the variable is not nil?
body: <pre><code>class LinkedList : NSObject
  {
      var head : Node?
      var tail : Node?
  
      func insertAtHead( newNode : Node )
      {
          if (head != nil) {
              newNode.next = head
              head?.prev = newNode
              head = newNode
          }
          else {
              head = newNode
          }
      }
  }
  </code></pre>
  
  <p>And my node class is:</p>
  
  <pre><code>class Node : NSObject
  {
      var value : Int = 0
      var next : Node?
      var prev : Node?
  }
  </code></pre>
  
  <p>My confusion is about the line <code>head?.prev = newNode</code> inside insertAtHead method. I already checked and confirmed that the head is not nil, why can't I just type <code>head.prev = newNode</code> in that case? Why should I use optional chaining?</p>