Mercurial > vim
diff runtime/doc/vim9.txt @ 26346:8be6413a8e27 v8.2.3704
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Commit: https://github.com/vim/vim/commit/ab36e6ae7b87b0295fb19270e4339a734875c6b1
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Nov 30 16:14:49 2021 +0000
patch 8.2.3704: Vim9: cannot use a list declaration in a :def function
Problem: Vim9: cannot use a list declaration in a :def function.
Solution: Make it work.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 30 Nov 2021 17:15:03 +0100 |
parents | bb2175e5ccee |
children | 80b555c4aed0 |
line wrap: on
line diff
--- a/runtime/doc/vim9.txt +++ b/runtime/doc/vim9.txt @@ -420,12 +420,11 @@ similar to how a function argument can b To ignore any remaining items: > [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. +possible. Each variable can have a type or infer it from the value: > + var [v1: number, v2] = GetValues() +Use this only when there is a list with values, declaring one variable per +line is much easier to read and change later. Constants ~