mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 14:36:16 +02:00
8a1ab709a4
attribute existence and to return an attribute from an attribute set, respectively. Example: `hasAttr "foo" {foo = 1;}'. They differ from the `?' and `.' operators in that the attribute name is an arbitrary expression. (NIX-61)
10 lines
231 B
Nix
10 lines
231 B
Nix
let {
|
|
as = { x = 123; y = 456; } // { z = 789; } // { z = 987; };
|
|
|
|
A = "a";
|
|
Z = "z";
|
|
|
|
body = if builtins.hasAttr A as
|
|
then builtins.getAttr A as
|
|
else assert builtins.hasAttr Z as; builtins.getAttr Z as;
|
|
}
|