summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-04-10 22:35:43 +0200
committerBram Moolenaar <Bram@vim.org>2021-04-10 22:35:43 +0200
commitf93bbd026205f36915312193784f987ad49fb114 (patch)
tree3d33a10b9e526aa7ed613bb4113df3406025632a /runtime
parente8e307818495d1a5d821df9bd4bde83add0520e5 (diff)
patch 8.2.2753: Vim9: cannot ignore an item in assignment unpackv8.2.2753
Problem: Vim9: cannot ignore an item in assignment unpack. Solution: Allow using an underscore.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/vim9.txt19
1 files changed, 12 insertions, 7 deletions
diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt
index 29fdab1488..6b676dfabd 100644
--- a/runtime/doc/vim9.txt
+++ b/runtime/doc/vim9.txt
@@ -335,6 +335,18 @@ The "g:" prefix is not needed for auto-load functions.
Since `&opt = value` is now assigning a value to option "opt", ":&" cannot be
used to repeat a `:substitute` command.
+For an unpack assignment the underscore can be used to ignore a list item,
+similar to how a function argument can be ignored: >
+ [a, _, c] = theList
+ [a, b; _] = longList
+
+< *E1092*
+Declaring more than one variable at a time, using the unpack notation, is
+currently not supported: >
+ var [v1, v2] = GetValues() # Error!
+That is because the type needs to be inferred from the list item type, which
+isn't that easy.
+
Constants ~
*vim9-const* *vim9-final*
@@ -368,13 +380,6 @@ The constant only applies to the value itself, not what it refers to. >
NAMES[1] = ["Emma"] # Error!
NAMES[1][0] = "Emma" # OK, now females[0] == "Emma"
-< *E1092*
-Declaring more than one variable at a time, using the unpack notation, is
-currently not supported: >
- var [v1, v2] = GetValues() # Error!
-That is because the type needs to be inferred from the list item type, which
-isn't that easy.
-
Omitting :call and :eval ~