title: What is difference between optional and decodeIfPresent when using Decodable for JSON Parsing?
body: <p>I am using <code>Codable</code> protocol from Swift 4 first time, I am not able to understand use of <code>decodeIfPresent</code> from <code>Decodable</code>. </p>
  
  <pre><code>/// Decodes a value of the given type for the given key, if present.
  ///
  /// This method returns `nil` if the container does not have a value associated with `key`, or if the value is null. The difference between these states can be distinguished with a `contains(_:)` call.
  ///
  /// - parameter type: The type of value to decode.
  /// - parameter key: The key that the decoded value is associated with.
  /// - returns: A decoded value of the requested type, or `nil` if the `Decoder` does not have an entry associated with the given key, or if the value is a null value.
  /// - throws: `DecodingError.typeMismatch` if the encountered encoded value is not convertible to the requested type.
  public func decodeIfPresent(_ type: String.Type, forKey key: KeyedDecodingContainer.Key) throws -&gt; String?
  </code></pre>
  
  <p>Here it suggest that it returns <code>nil</code>, if value not present with associated key. If this is the only reason , then how it differ from optional property, as optional variable also set to <code>nil</code> if value is not present in response. </p>