Nix Language Quirks: Difference between revisions
imported>Makefu No edit summary |
imported>Danbst added x:x example |
||
| Line 90: | Line 90: | ||
error: attribute ‘x’ at (string):1:31 already defined at (string):1:24</nowiki> | error: attribute ‘x’ at (string):1:31 already defined at (string):1:24</nowiki> | ||
This makes it a sane citizen of Nix lanugage... except it has a twin, called <code>{ inherit ...; }</code>. They DON'T do the same - <code>let inherit ...</code> adds let-bindings, and <code>{ inherit ...; }</code> adds attributes to a record. | This makes it a sane citizen of Nix lanugage... except it has a twin, called <code>{ inherit ...; }</code>. They DON'T do the same - <code>let inherit ...</code> adds let-bindings, and <code>{ inherit ...; }</code> adds attributes to a record. | ||
== Q: What is the shortest <code>id</code> function definition? == | |||
A: <code>x: x</code> | |||
Q: Why not <code>x:x</code>? | |||
A: | |||
<nowiki> | |||
nix-repl> builtins.typeOf (x: x) | |||
"lambda" | |||
nix-repl> builtins.typeOf (x:x) | |||
"string"</nowiki> | |||
! [https://github.com/NixOS/nix/issues/836 Can you figure out how can this happens before reading explanation?] | |||