From 2bf0778715ad811b38a12c8c3ed827dfd06f0f10 Mon Sep 17 00:00:00 2001
From: Marya <111139605+MaryaBelanger@users.noreply.github.com>
Date: Tue, 12 Mar 2024 08:40:21 -0700
Subject: [PATCH] Add spread to Operators page (#5640)
Fixes #5599
Fixes #5635
---
src/content/language/operators.md | 56 +++++++++++++++++++++----------
1 file changed, 38 insertions(+), 18 deletions(-)
diff --git a/src/content/language/operators.md b/src/content/language/operators.md
index cecdd9ab44..42c2a48e91 100644
--- a/src/content/language/operators.md
+++ b/src/content/language/operators.md
@@ -19,24 +19,25 @@ and [operator precedence](#operator-precedence-example) from highest to lowest,
which are an **approximation** of Dart's operator relationships.
You can implement many of these [operators as class members][].
-| Description | Operator | Associativity |
-|--------------------------|----------------------------------------------------------------------------------------------------|---------------|
-| unary postfix | *`expr`*`++` *`expr`*`--` `()` `[]` `?[]` `.` `?.` `!` | None |
-| unary prefix | `-`*`expr`* `!`*`expr`* `~`*`expr`* `++`*`expr`* `--`*`expr`* `await` *`expr`* | None |
-| multiplicative | `*` `/` `%` `~/` | Left |
-| additive | `+` `-` | Left |
-| shift | `<<` `>>` `>>>` | Left |
-| bitwise AND | `&` | Left |
-| bitwise XOR | `^` | Left |
-| bitwise OR | |
| Left |
-| relational and type test | `>=` `>` `<=` `<` `as` `is` `is!` | None |
-| equality | `==` `!=` | None |
-| logical AND | `&&` | Left |
-| logical OR | ||
| Left |
-| if null | `??` | Left |
-| conditional | *`expr1`* `?` *`expr2`* `:` *`expr3`* | Right |
-| cascade | `..` `?..` | Left |
-| assignment | `=` `*=` `/=` `+=` `-=` `&=` `^=` *etc.* | Right |
+| Description | Operator | Associativity |
+|-----------------------------------------|----------------------------------------------------------------------------------------------------|---------------|
+| unary postfix | *`expr`*`++` *`expr`*`--` `()` `[]` `?[]` `.` `?.` `!` | None |
+| unary prefix | `-`*`expr`* `!`*`expr`* `~`*`expr`* `++`*`expr`* `--`*`expr`* `await` *`expr`* | None |
+| multiplicative | `*` `/` `%` `~/` | Left |
+| additive | `+` `-` | Left |
+| shift | `<<` `>>` `>>>` | Left |
+| bitwise AND | `&` | Left |
+| bitwise XOR | `^` | Left |
+| bitwise OR | |
| Left |
+| relational and type test | `>=` `>` `<=` `<` `as` `is` `is!` | None |
+| equality | `==` `!=` | None |
+| logical AND | `&&` | Left |
+| logical OR | ||
| Left |
+| if null | `??` | Left |
+| conditional | *`expr1`* `?` *`expr2`* `:` *`expr3`* | Right |
+| cascade | `..` `?..` | Left |
+| assignment | `=` `*=` `/=` `+=` `-=` `&=` `^=` *etc.* | Right |
+| spread ([See note](#spread-operators)) | `...` `...?` | None |
{:.table .table-striped}
@@ -500,6 +501,25 @@ Strictly speaking, the "double dot" notation for cascades isn't an operator.
It's just part of the Dart syntax.
:::
+## Spread operators
+
+Spread operators evaluate an expression that yields a collection,
+unpacks the resulting values, and inserts them into another collection.
+
+**The spread operator isn't actually an operator expression**.
+The `...`/`...?` syntax is part of the collection literal itself.
+So, you can learn more about spread operators on the
+[Collections](/language/collections#spread-operators) page.
+
+Because it isn't an operator, the syntax doesn't
+have any "[operator precedence](#operators)".
+Effectively, it has the lowest "precedence" —
+any kind of expression is valid as the spread target, such as:
+
+```dart
+[...a + b]
+```
+
## Other operators
You've seen most of the remaining operators in other examples: