comparison runtime/doc/eval.txt @ 34290:167d80fce1b1

runtime(doc): Clarify list-concatenation a bit more Commit: https://github.com/vim/vim/commit/c9c2e2d2ff4429a6b5876ee919f15c1dc0018e86 Author: qeatzy <qeatzy@users.noreply.github.com> Date: Wed Feb 7 17:52:25 2024 +0100 runtime(doc): Clarify list-concatenation a bit more Make doc list-concatenation more clear as for += and extend(). 1. describe `+=` for list-concatenation more accurately 2. add `extend()` example for list-concatenation 3. Fix CI errors for missing helptags reference |+=| closes: #13983 Signed-off-by: qeatzy <qeatzy@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Wed, 07 Feb 2024 18:00:04 +0100
parents 6df143135376
children 6d00518cb316
comparison
equal deleted inserted replaced
34289:3b7889be5f34 34290:167d80fce1b1
1 *eval.txt* For Vim version 9.1. Last change: 2024 Feb 06 1 *eval.txt* For Vim version 9.1. Last change: 2024 Feb 07
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
301 301
302 List concatenation ~ 302 List concatenation ~
303 *list-concatenation* 303 *list-concatenation*
304 Two lists can be concatenated with the "+" operator: > 304 Two lists can be concatenated with the "+" operator: >
305 :let longlist = mylist + [5, 6] 305 :let longlist = mylist + [5, 6]
306 A list can be concatenated with another one in place using the "+=" operator or |extend()|: >
306 :let mylist += [7, 8] 307 :let mylist += [7, 8]
308 :call extend(mylist, [7, 8])
307 309
308 To prepend or append an item, turn the item into a list by putting [] around 310 To prepend or append an item, turn the item into a list by putting [] around
309 it. To change a list in-place, refer to |list-modification| below. 311 it. To change a list in-place, refer to |list-modification| below.
310 312
311 313
423 425
424 To change part of a list you can specify the first and last item to be 426 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: > 427 modified. The value must at least have the number of items in the range: >
426 :let list[3:5] = [3, 4, 5] 428 :let list[3:5] = [3, 4, 5]
427 429
428 To add items to a List in-place, you can use the |+=| operator: > 430 To add items to a List in-place, you can use the += operator
431 |list-concatenation|: >
429 :let listA = [1, 2] 432 :let listA = [1, 2]
430 :let listA += [3, 4] 433 :let listA += [3, 4]
431 < 434 <
432 When two variables refer to the same List, changing one List in-place will 435 When two variables refer to the same List, changing one List in-place will
433 cause the referenced List to be changed in-place: > 436 cause the referenced List to be changed in-place: >