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>
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 19b9bc9..062da08 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -2093,7 +2093,7 @@
Returns an empty List or String if {fromlist} and {tolist} are
identical.
- Examples:
+ Examples: >
:echo diff(['abc'], ['xxx'])
@@ -1 +1 @@
-abc
@@ -2103,7 +2103,7 @@
[{'from_idx': 0, 'from_count': 1, 'to_idx': 0, 'to_count': 1}]
:echo diff(readfile('oldfile'), readfile('newfile'))
:echo diff(getbufline(5, 1, '$'), getbufline(6, 1, '$'))
-
+<
For more examples, refer to |diff-func-examples|
Can also be used as a |method|: >
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 574b9c9..75ea2c7 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt* For Vim version 9.1. Last change: 2024 Feb 05
+*eval.txt* For Vim version 9.1. Last change: 2024 Feb 06
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -425,6 +425,18 @@
modified. The value must at least have the number of items in the range: >
:let list[3:5] = [3, 4, 5]
+To add items to a List in-place, you can use the |+=| operator: >
+ :let listA = [1, 2]
+ :let listA += [3, 4]
+<
+When two variables refer to the same List, changing one List in-place will
+cause the referenced List to be changed in-place: >
+ :let listA = [1, 2]
+ :let listB = listA
+ :let listB += [3, 4]
+ :echo listA
+ [1, 2, 3, 4]
+<
Adding and removing items from a list is done with functions. Here are a few
examples: >
:call insert(list, 'a') " prepend item 'a'