From 7355947f12068a1f899865b80c8b74f011c98f9c Mon Sep 17 00:00:00 2001 From: qaz Date: Sat, 15 Nov 2025 20:58:17 +0100 Subject: [PATCH 1/2] Added explanations and examples for brackets to operators page --- lang-guide/chapters/operators.md | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/lang-guide/chapters/operators.md b/lang-guide/chapters/operators.md index dfa945956ac..60cc00a3e58 100644 --- a/lang-guide/chapters/operators.md +++ b/lang-guide/chapters/operators.md @@ -43,10 +43,34 @@ Nushell provides support for these bitwise operators: ## Brackets -TODO - -### `(` and `)` - ### `[` and `]` +The square brackets can be used to make [lists](types/basic_types/list.md). +```nu +~> [ 1, 2, 3 ] +╭───┬───╮ +│ 0 │ 1 │ +│ 1 │ 2 │ +│ 2 │ 3 │ +╰───┴───╯ +``` ### `{` and `}` +The curly brackets can be used to make [records](types/basic_types/record.md) and [closures](types/basic_types/closure.md). +```nu +~> { a: 1, b: 2 } +╭───┬───╮ +│ a │ 1 │ +│ b │ 2 │ +╰───┴───╯ +``` + +### `(` and `)` +The round brackets can be used to denote sub-expressions. +```nu +~> # This would fail without parentheses +~> { a: ('aaa' | str length), b: 2 } +╭───┬───╮ +│ a │ 3 │ +│ b │ 2 │ +╰───┴───╯ +``` From 9d2f0bdf8f948ec39878ac1d7605b9ac3cf92b34 Mon Sep 17 00:00:00 2001 From: qaz Date: Sun, 16 Nov 2025 08:57:32 +0100 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com> --- lang-guide/chapters/operators.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lang-guide/chapters/operators.md b/lang-guide/chapters/operators.md index 60cc00a3e58..9243ffc59c1 100644 --- a/lang-guide/chapters/operators.md +++ b/lang-guide/chapters/operators.md @@ -44,7 +44,7 @@ Nushell provides support for these bitwise operators: ## Brackets ### `[` and `]` -The square brackets can be used to make [lists](types/basic_types/list.md). +The brackets can be used to make [lists](types/basic_types/list.md). ```nu ~> [ 1, 2, 3 ] ╭───┬───╮ @@ -55,7 +55,7 @@ The square brackets can be used to make [lists](types/basic_types/list.md). ``` ### `{` and `}` -The curly brackets can be used to make [records](types/basic_types/record.md) and [closures](types/basic_types/closure.md). +The braces can be used to make [records](types/basic_types/record.md) and [closures](types/basic_types/closure.md). ```nu ~> { a: 1, b: 2 } ╭───┬───╮ @@ -65,7 +65,7 @@ The curly brackets can be used to make [records](types/basic_types/record.md) an ``` ### `(` and `)` -The round brackets can be used to denote sub-expressions. +The parentheses can be used to denote sub-expressions. ```nu ~> # This would fail without parentheses ~> { a: ('aaa' | str length), b: 2 }