Add table with most important Nix operators

This commit is contained in:
Vincent Ambo 2019-08-07 16:08:06 +01:00 committed by Vincent Ambo
parent d113a91ae8
commit 19d6d5a16c

View file

@ -15,6 +15,7 @@ important is missing.
- [Overview](#overview)
- [Language constructs](#language-constructs)
- [Primitives / literals](#primitives--literals)
- [Operators](#operators)
- [Variable bindings](#variable-bindings)
- [Functions](#functions)
- [Multiple arguments (currying)](#multiple-arguments-currying)
@ -104,6 +105,28 @@ second line
rec { a = 15; b = a * 2; }
```
## Operators
Nix has several operators, most of which are unsurprising:
| Syntax | Description |
|----------------------|-----------------------------------------------------------------------------|
| `+`, `-`, `*`, `/` | Numerical operations |
| `+` | String concatenation |
| `++` | List concatenation |
| `==` | Equality |
| `>`, `>=`, `<`, `<=` | Ordering comparators |
| `&&` | Logical `AND` |
| `\|\|` | Logical `OR` |
| `e1 -> e2` | Logical implication (i.e. `!e1 \|\| e2`) |
| `!` | Boolean negation |
| `set.attr` | Access attribute `attr` in attribute set `set` |
| `set ? attribute` | Test whether attribute set contains an attribute |
| `left // right` | Merge `left` & `right` attribute sets, with the right set taking precedence |
Make sure to understand the `//`-operator, as it is used quite a lot and is
probably the least familiar one.
## Variable bindings
Bindings in Nix are introduced locally via `let` expressions, which make some