Skip to content

Commit a1bc975

Browse files
QazCetelicfdncred
andauthored
Added explanations and examples for brackets to operators page (#2068)
* Added explanations and examples for brackets to operators page * Apply suggestions from code review Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com> --------- Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
1 parent c52cbda commit a1bc975

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

lang-guide/chapters/operators.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,34 @@ Nushell provides support for these bitwise operators:
4343

4444
## Brackets
4545

46-
TODO
47-
48-
### `(` and `)`
49-
5046
### `[` and `]`
47+
The brackets can be used to make [lists](types/basic_types/list.md).
48+
```nu
49+
~> [ 1, 2, 3 ]
50+
╭───┬───╮
51+
│ 0 │ 1 │
52+
│ 1 │ 2 │
53+
│ 2 │ 3 │
54+
╰───┴───╯
55+
```
5156

5257
### `{` and `}`
58+
The braces can be used to make [records](types/basic_types/record.md) and [closures](types/basic_types/closure.md).
59+
```nu
60+
~> { a: 1, b: 2 }
61+
╭───┬───╮
62+
│ a │ 1 │
63+
│ b │ 2 │
64+
╰───┴───╯
65+
```
66+
67+
### `(` and `)`
68+
The parentheses can be used to denote sub-expressions.
69+
```nu
70+
~> # This would fail without parentheses
71+
~> { a: ('aaa' | str length), b: 2 }
72+
╭───┬───╮
73+
│ a │ 3 │
74+
│ b │ 2 │
75+
╰───┴───╯
76+
```

0 commit comments

Comments
 (0)