You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* Postfix trailers: `.attr`, [i], [s:e], (args), chained. A trailer must start on the same line, so a statement boundary ends the chain (else `x = []` ⏎ `[i]` parses as `[][i]`). */
298
298
pub(super)fnpostfix_tail(&mutself){
299
299
loop{
300
-
matchself.peek(){
300
+
matchself.peek_same_line(){
301
301
Some(TokenType::Lsqb) => {
302
302
self.advance();
303
303
let is_slice = matches!(self.peek(),Some(TokenType::Colon));
// First element already emitted; list_tail consolidates if a later `*` appears.
95
+
self.list_tail(1,false);
96
+
}
97
+
}
98
+
99
+
/* Finishes a `{}` dict after the first pair. `pairs` = loose key/val pairs on the stack; `incremental` = a Dict object is already on the stack. On the first `**` the loose pairs are consolidated with `BuildDict pairs`, then merges use `DictUpdate`/`MapAdd`. */
/* Like `peek` but stops at the logical-line boundary: a `Newline` yields `None` (unconsumed) so postfix trailers don't bind across statements. `Nl`/`Comment` (bracket-internal) still skip, so multiline `()`/`[]`/`{}` are unaffected. */
Err(VmErr::TypeMsg(s!("'<' not supported between instances of '",strself.type_name(a),"' and '",strself.type_name(b),"'")))
270
282
}
271
283
284
+
/* Lexicographic `<` for sequences: first differing element decides; otherwise the shorter is less. Recurses through `lt_vals`, so nested sequences and mixed element types are handled (and rejected) consistently. */
{"src": "[print(x) for x in range(2)]\nd = {}\n[d.update({x: x}) for x in range(2)]\nprint(d[0], d[1])\nxs = []\n[xs.append(x) for x in range(2)]\nprint(xs)", "output": ["0", "1", "0 1", "[0, 1]"]},
Copy file name to clipboardExpand all lines: docs/pages/language/data-types.md
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -317,6 +317,25 @@ set()
317
317
True
318
318
```
319
319
320
+
## Unpacking in literals
321
+
322
+
`*` spreads an iterable into a list/set literal; `**` spreads a mapping into a dict literal. Mix freely with regular elements; for dicts, later keys win.
0 commit comments