lib.overrideExisting: Better example

This commit is contained in:
Silvan Mosberger 2018-09-17 23:28:47 +02:00
parent afd8620621
commit c7104d97c8
No known key found for this signature in database
GPG Key ID: 9424360B4B85C9E7

View File

@ -435,9 +435,12 @@ rec {
useful for deep-overriding. useful for deep-overriding.
Example: Example:
x = { a = { b = 4; c = 3; }; } overrideExisting {} { a = 1; }
overrideExisting x { a = { b = 6; d = 2; }; } => {}
=> { a = { b = 6; d = 2; }; } overrideExisting { b = 2; } { a = 1; }
=> { b = 2; }
overrideExisting { a = 3; b = 2; } { a = 1; }
=> { a = 1; b = 2; }
*/ */
overrideExisting = old: new: overrideExisting = old: new:
mapAttrs (name: value: new.${name} or value) old; mapAttrs (name: value: new.${name} or value) old;