mirror of
https://github.com/NixOS/nix
synced 2025-07-08 02:43:54 +02:00
* New built-in function `builtins.attrNames' that returns the
names of the attributes in an attribute set.
This commit is contained in:
parent
5e6699188f
commit
1a7e88bbd9
4 changed files with 51 additions and 0 deletions
1
tests/lang/eval-okay-attrnames.exp
Normal file
1
tests/lang/eval-okay-attrnames.exp
Normal file
|
@ -0,0 +1 @@
|
|||
Str("newxfoonewxy",[])
|
11
tests/lang/eval-okay-attrnames.nix
Normal file
11
tests/lang/eval-okay-attrnames.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
let
|
||||
|
||||
attrs = {y = "y"; x = "x"; foo = "foo";} // rec {x = "newx"; bar = x;};
|
||||
|
||||
names = builtins.attrNames attrs;
|
||||
|
||||
values = map (name: builtins.getAttr name attrs) names;
|
||||
|
||||
in concat values
|
Loading…
Add table
Add a link
Reference in a new issue