Nix (language): Difference between revisions

imported>Rovanion
Corrected the syntax highlighting in the new function sections
imported>Vincentbernat
"@" pattern captures all arguments, not only the extra ones
Line 135: Line 135:
</syntaxHighlight>
</syntaxHighlight>


You can also store away the extra arguments in a name of your chosing using the <code>@</code> pattern.
You can also store away the arguments in a name of your chosing using the <code>@</code> pattern.


<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>
add_a_b = rest@{ a, b, ... }: a + b + rest.c
add_a_b = args@{ a, b, ... }: a + b + args.c
add_a_b { a=5; b=2; c=10; }
add_a_b { a=5; b=2; c=10; }
17
17