diff options
author | Ana Hobden <operator@hoverbear.org> | 2023-05-12 11:03:09 -0700 |
---|---|---|
committer | Ana Hobden <operator@hoverbear.org> | 2023-05-12 11:03:09 -0700 |
commit | 17fb346ec6413644d5edb12555794b933be7cbbe (patch) | |
tree | f43644db833671dc40064a5061388e5e5537fa1e /doc | |
parent | 916da456cbc1ae0142d4a7c0162809475767a54a (diff) |
Describe the or operation on attribute sets slightly more
Diffstat (limited to 'doc')
-rw-r--r-- | doc/manual/src/language/operators.md | 2 | ||||
-rw-r--r-- | doc/manual/src/language/values.md | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/doc/manual/src/language/operators.md b/doc/manual/src/language/operators.md index a07d976ad..3e929724d 100644 --- a/doc/manual/src/language/operators.md +++ b/doc/manual/src/language/operators.md @@ -36,7 +36,7 @@ ## Attribute selection Select the attribute denoted by attribute path *attrpath* from [attribute set] *attrset*. -If the attribute doesn’t exist, return *value* if provided, otherwise abort evaluation. +If the attribute doesn’t exist, return the *expr* after `or` if provided, otherwise abort evaluation. <!-- FIXME: the following should to into its own language syntax section, but that needs more work to fit in well --> diff --git a/doc/manual/src/language/values.md b/doc/manual/src/language/values.md index c85124278..9d0301753 100644 --- a/doc/manual/src/language/values.md +++ b/doc/manual/src/language/values.md @@ -190,13 +190,17 @@ instance, ``` evaluates to `"Foo"`. It is possible to provide a default value in an -attribute selection using the `or` keyword. For example, +attribute selection using the `or` keyword: ```nix { a = "Foo"; b = "Bar"; }.c or "Xyzzy" ``` -will evaluate to `"Xyzzy"` because there is no `c` attribute in the set. +```nix +{ a = "Foo"; b = "Bar"; }.c.d.e.f.g or "Xyzzy" +``` + +will both evaluate to `"Xyzzy"` because there is no `c` attribute in the set. You can use arbitrary double-quoted strings as attribute names: |