Nix (language): Difference between revisions

imported>Nh2
mention non-shadowing of `with` statement
imported>Nh2
Line 294: Line 294:


==== <code>with</code> statement ====
==== <code>with</code> statement ====
The <code>with</code> statement ([https://nixos.org/manual/nix/stable/#idm140737321918544 link to Nix manual section]) introduces an attrset's value contents into the lexical scope of into the expression which follows. This means that it brings all keys within that set into scope in that expression. So, you don't need to use the dot notation.
The <code>with</code> statement ([https://nixos.org/manual/nix/stable/#idm140737321918544 link to Nix manual section]) introduces an attrset's value contents into the lexical scope of into the expression which follows. This means that it brings all keys within that set (that do not already exist in an outer scope) into scope in that expression. So, you don't need to use the dot notation.


Example:
Example: