lib.overrideExisting: Better example
This commit is contained in:
parent
afd8620621
commit
c7104d97c8
@ -435,9 +435,12 @@ rec {
|
||||
useful for deep-overriding.
|
||||
|
||||
Example:
|
||||
x = { a = { b = 4; c = 3; }; }
|
||||
overrideExisting x { a = { b = 6; d = 2; }; }
|
||||
=> { a = { b = 6; d = 2; }; }
|
||||
overrideExisting {} { a = 1; }
|
||||
=> {}
|
||||
overrideExisting { b = 2; } { a = 1; }
|
||||
=> { b = 2; }
|
||||
overrideExisting { a = 3; b = 2; } { a = 1; }
|
||||
=> { a = 1; b = 2; }
|
||||
*/
|
||||
overrideExisting = old: new:
|
||||
mapAttrs (name: value: new.${name} or value) old;
|
||||
|
Loading…
Reference in New Issue
Block a user