summaryrefslogtreecommitdiffstats
path: root/runtime/doc/if_lua.txt
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-06-27 12:32:57 +0200
committerBram Moolenaar <Bram@vim.org>2020-06-27 12:32:57 +0200
commitbd84617d1a6766efd59c94aabebb044bef805b99 (patch)
tree57fc315043f9e042b25d78e5c7ebd39ff5b3ad8d /runtime/doc/if_lua.txt
parent7147820cb978f5b179cfec2f9d8b7774e28d43e0 (diff)
patch 8.2.1066: Lua arrays are zero basedv8.2.1066
Problem: Lua arrays are zero based. Solution: Make Lua arrays one based. (Prabir Shrestha, closes #6347) Note: this is not backwards compatible.
Diffstat (limited to 'runtime/doc/if_lua.txt')
-rw-r--r--runtime/doc/if_lua.txt12
1 files changed, 8 insertions, 4 deletions
diff --git a/runtime/doc/if_lua.txt b/runtime/doc/if_lua.txt
index 170f861ff0..f32be7c379 100644
--- a/runtime/doc/if_lua.txt
+++ b/runtime/doc/if_lua.txt
@@ -217,11 +217,15 @@ Vim's syntax for lists. Since lists are objects, changes in list references in
Lua are reflected in Vim and vice-versa. A list "l" has the following
properties and methods:
+NOTE: In patch 8.2.1066 array indexes were changed from zero-based to
+one-based. You can check with: >
+ if has("patch-8.2.1066")
+
Properties
----------
o "#l" is the number of items in list "l", equivalent to "len(l)"
in Vim.
- o "l[k]" returns the k-th item in "l"; "l" is zero-indexed, as in Vim.
+ o "l[k]" returns the k-th item in "l"; "l" is one-indexed, as in Lua.
To modify the k-th item, simply do "l[k] = newitem"; in
particular, "l[k] = nil" removes the k-th item from "l".
o "l()" returns an iterator for "l".
@@ -237,11 +241,11 @@ Examples:
:let l = [1, 'item']
:lua l = vim.eval('l') -- same 'l'
:lua l:add(vim.list())
- :lua l[0] = math.pi
+ :lua l[1] = math.pi
:echo l[0] " 3.141593
- :lua l[0] = nil -- remove first item
+ :lua l[1] = nil -- remove first item
:lua l:insert(true, 1)
- :lua print(l, #l, l[0], l[1], l[-1])
+ :lua print(l, #l, l[1], l[2])
:lua for item in l() do print(item) end
<