Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 579 Bytes

replace-duplicates-in-a-keyword-list.md

File metadata and controls

26 lines (19 loc) · 579 Bytes

Replace Duplicates In A Keyword List

Use the Keyword.put function to replace duplicate key entries in a keyword list.

If there are no duplicate entries, the entry will just be added.

Keyword.put([a: 1], :b, 2)
[b: 2, a: 1]

If there is a duplicate entry, it will be replaced by the new value.

> Keyword.put([b: 1, a: 1], :b, 2)
[b: 2, a: 1]

If there are multiple duplicate entries, they will all be replaced.

> Keyword.put([b: 3, b: 4, a: 1], :b, 2)
[b: 2, a: 1]