···1415 /* Return an attribute from nested attribute sets.
160000000017 Example:
18 x = { a = { b = 3; }; }
19 # ["a" "b"] is equivalent to x.a.b
···50 attrByPath' 0 set;
5152 /* Return if an attribute from nested attribute set exists.
000000005354 **Laws**:
55 1. ```nix
···176177 /* Like `attrByPath`, but without a default value. If it doesn't find the
178 path it will throw an error.
00000000179180 Example:
181 x = { a = { b = 3; }; }
···1415 /* Return an attribute from nested attribute sets.
1617+ Nix has an [attribute selection operator `. or`](https://nixos.org/manual/nix/stable/language/operators#attribute-selection) which is sufficient for such queries, as long as the number of attributes is static. For example:
18+19+ ```nix
20+ (x.a.b or 6) == attrByPath ["a" "b"] 6 x
21+ # and
22+ (x.${f p}."example.com" or 6) == attrByPath [ (f p) "example.com" ] 6 x
23+ ```
24+25 Example:
26 x = { a = { b = 3; }; }
27 # ["a" "b"] is equivalent to x.a.b
···58 attrByPath' 0 set;
5960 /* Return if an attribute from nested attribute set exists.
61+62+ Nix has a [has attribute operator `?`](https://nixos.org/manual/nix/stable/language/operators#has-attribute), which is sufficient for such queries, as long as the number of attributes is static. For example:
63+64+ ```nix
65+ (x?a.b) == hasAttryByPath ["a" "b"] x
66+ # and
67+ (x?${f p}."example.com") == hasAttryByPath [ (f p) "example.com" ] x
68+ ```
6970 **Laws**:
71 1. ```nix
···192193 /* Like `attrByPath`, but without a default value. If it doesn't find the
194 path it will throw an error.
195+196+ Nix has an [attribute selection operator](https://nixos.org/manual/nix/stable/language/operators#attribute-selection) which is sufficient for such queries, as long as the number of attributes is static. For example:
197+198+ ```nix
199+ x.a.b == getAttrByPath ["a" "b"] x
200+ # and
201+ x.${f p}."example.com" == getAttrByPath [ (f p) "example.com" ] x
202+ ```
203204 Example:
205 x = { a = { b = 3; }; }