comparison 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
comparison
equal deleted inserted replaced
26345:1707aa6d46a2 26346:8be6413a8e27
418 similar to how a function argument can be ignored: > 418 similar to how a function argument can be ignored: >
419 [a, _, c] = theList 419 [a, _, c] = theList
420 To ignore any remaining items: > 420 To ignore any remaining items: >
421 [a, b; _] = longList 421 [a, b; _] = longList
422 422
423 < *E1092*
424 Declaring more than one variable at a time, using the unpack notation, is 423 Declaring more than one variable at a time, using the unpack notation, is
425 currently not supported: > 424 possible. Each variable can have a type or infer it from the value: >
426 var [v1, v2] = GetValues() # Error! 425 var [v1: number, v2] = GetValues()
427 That is because the type needs to be inferred from the list item type, which 426 Use this only when there is a list with values, declaring one variable per
428 isn't that easy. 427 line is much easier to read and change later.
429 428
430 429
431 Constants ~ 430 Constants ~
432 *vim9-const* *vim9-final* 431 *vim9-const* *vim9-final*
433 How constants work varies between languages. Some consider a variable that 432 How constants work varies between languages. Some consider a variable that