Note that or
works for nested attribute access
This commit is contained in:
parent
3236b7ff28
commit
d28d30477a
1 changed files with 3 additions and 1 deletions
|
@ -348,7 +348,7 @@ in set.a or 23
|
||||||
Since the attribute `a` exists, this will return `42`.
|
Since the attribute `a` exists, this will return `42`.
|
||||||
|
|
||||||
|
|
||||||
```
|
```nix
|
||||||
# ... or fall back to a default if there is no such key
|
# ... or fall back to a default if there is no such key
|
||||||
let set = { };
|
let set = { };
|
||||||
in set.a or 23
|
in set.a or 23
|
||||||
|
@ -357,6 +357,8 @@ in set.a or 23
|
||||||
Since the attribute `a` does not exist, this will fall back to returning the
|
Since the attribute `a` does not exist, this will fall back to returning the
|
||||||
default value `23`.
|
default value `23`.
|
||||||
|
|
||||||
|
Note that `or` expressions also work for nested attribute set access.
|
||||||
|
|
||||||
# Standard libraries
|
# Standard libraries
|
||||||
|
|
||||||
Yes, libraries, plural.
|
Yes, libraries, plural.
|
||||||
|
|
Loading…
Reference in a new issue