setAttrByPath
lib.setAttrByPath
Docs pulled from | This Revision | 1 day ago
Create a new attribute set with value
set at the nested attribute location specified in attrPath
.
Inputs
attrPath
-
A list of strings representing the attribute path to set
value
-
The value to set at the location described by
attrPath
Type
setAttrByPath :: [String] -> Any -> AttrSet
Examples
lib.attrsets.setAttrByPath
usage example
setAttrByPath ["a" "b"] 3
=> { a = { b = 3; }; }
Noogle detected
Implementation
The following is the current implementation of this function.
setAttrByPath =
attrPath:
value:
let
len = length attrPath;
atDepth = n:
if n == len
then value
else { ${elemAt attrPath n} = atDepth (n + 1); };
in atDepth 0;