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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With