Instance Method インスタンスメソッド

decodeIfPresent(_:forKey:)

Decodes a value of the given type for the given key, if present. 指定された型の値を与えられたキーに対してデコードします、もし存在するならば。

Declaration 宣言

func decodeIfPresent(_ type: Int16.Type, forKey key: Self.Key) throws -> Int16?

Parameters パラメータ

type

The type of value to decode. この型の値にデコードする。

key

The key that the decoded value is associated with. デコードされた値が関連付けられるキー。

Return Value 戻り値

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. 要求された型にデコード済みの値、またはnil、もしDecoderが与えられたキーに関連する登録項目を持たない場合は、またはその値がnull値の場合は。

Discussion 解説

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. このメソッドは、nilを、そのコンテナがkeyと関連付けられる値を持たないならば、またはその値がnullならば、返します。これらの状態の相違は、contains(_:)呼び出しで見分けることが可能です。