Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

f#

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

The docs do not mention this case.

like image 327
sdgfsdh Avatar asked Dec 11 '22 06:12

sdgfsdh


1 Answers

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.

like image 112
Fyodor Soikin Avatar answered Dec 19 '22 00:12

Fyodor Soikin