What is the behaviour of Map.ofSeq with duplicate keys?

  • A+
Category:Languages

What is the behaviour of Map.ofSeq when the same key occurs twice?

The docs do not mention this case.

 


The source code indicates that construction of a Map from a sequence is achieved via multiple calls of add, performed in the order of the source collection, thus resulting in the semantics of "last write wins".

However, since the documentation does not mention this property, it would be unwise to rely on it in production code. As it stands, this behaviour is an internal implementation detail, and could change in a subsequent version of the standard library.

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: