comparison runtime/doc/eval.txt @ 34288:6df143135376 v9.1.0080

patch 9.1.0080: unexpected error for modifying final list using += Commit: https://github.com/vim/vim/commit/1af35631f85d2fcdc83c5d457af8273697f5146a Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Tue Feb 6 11:03:36 2024 +0100 patch 9.1.0080: unexpected error for modifying final list using += Problem: unexpected error for modifying final list using += operator (Ernie Rael) Solution: Allow List value modification of a final variable using += operator (Yegappan Lakshmanan) fixes: #13745 fixes: #13959 closes: #13962 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 06 Feb 2024 11:15:05 +0100
parents e67eafbceca9
children 167d80fce1b1
comparison
equal deleted inserted replaced
34287:4fb3789423a3 34288:6df143135376
1 *eval.txt* For Vim version 9.1. Last change: 2024 Feb 05 1 *eval.txt* For Vim version 9.1. Last change: 2024 Feb 06
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
423 423
424 To change part of a list you can specify the first and last item to be 424 To change part of a list you can specify the first and last item to be
425 modified. The value must at least have the number of items in the range: > 425 modified. The value must at least have the number of items in the range: >
426 :let list[3:5] = [3, 4, 5] 426 :let list[3:5] = [3, 4, 5]
427 427
428 To add items to a List in-place, you can use the |+=| operator: >
429 :let listA = [1, 2]
430 :let listA += [3, 4]
431 <
432 When two variables refer to the same List, changing one List in-place will
433 cause the referenced List to be changed in-place: >
434 :let listA = [1, 2]
435 :let listB = listA
436 :let listB += [3, 4]
437 :echo listA
438 [1, 2, 3, 4]
439 <
428 Adding and removing items from a list is done with functions. Here are a few 440 Adding and removing items from a list is done with functions. Here are a few
429 examples: > 441 examples: >
430 :call insert(list, 'a') " prepend item 'a' 442 :call insert(list, 'a') " prepend item 'a'
431 :call insert(list, 'a', 3) " insert item 'a' before list[3] 443 :call insert(list, 'a', 3) " insert item 'a' before list[3]
432 :call add(list, "new") " append String item 444 :call add(list, "new") " append String item