title: Swift Decodable Optional Key
body: <p><em>(This is a follow-up from this question: <a href="https://stackoverflow.com/q/46723619/819340">Using Decodable protocol with multiples keys</a>.)</em></p>
  
  <p>I have the following Swift code:</p>
  
  <pre><code>let additionalInfo = try values.nestedContainer(keyedBy: UserInfoKeys.self, forKey: .age)
  age = try additionalInfo.decodeIfPresent(Int.self, forKey: .realage)
  </code></pre>
  
  <p>I know that if I use <code>decodeIfPresent</code> and don't have the property it will still handle it correctly if it's an optional variable.</p>
  
  <p>For example the following JSON works to parse it using the code above.</p>
  
  <pre><code>{
      "firstname": "Test",
      "lastname": "User",
      "age": {"realage": 29}
  }
  </code></pre>
  
  <p>And the following JSON works as well.</p>
  
  <pre><code>{
      "firstname": "Test",
      "lastname": "User",
      "age": {"notrealage": 30}
  }
  </code></pre>
  
  <p>But the following doesn't work.</p>
  
  <pre><code>{
      "firstname": "Test",
      "lastname": "User"
  }
  </code></pre>
  
  <p>How can I make all 3 examples work? Is there something similar to <code>decodeIfPresent</code> for <code>nestedContainer</code>?</p>