> On Dec 28, 2017, at 1:57 PM, Ingo Maier via swift-users 
> <swift-users@swift.org> wrote:
> 
> Can anybody tell why the decode methods in UnkeyedDecodingContainer
> are marked mutating but those in KeyedDecodingContainerProtocol and
> SingleValueDecodingContainer are not? Is it a simple oversight or is
> there a reason for this? It seems to me that all of them should be
> mutating.


The `UnkeyedDecodingContainer.decode(_:)` methods consume values as they decode 
them; that is, the first call returns the first value, the second call returns 
the second value, etc. The ones in the other containers don't consume values; 
in theory, you could decode the same key twice and you should get the same 
value both times. So the UnkeyedDecodingContainer methods are mutating, but the 
other containers' methods are not.

-- 
Brent Royal-Gordon
Architechies

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to