diff options
author | Gregory Anders <greg@gpanders.com> | 2023-04-19 07:05:04 -0600 |
---|---|---|
committer | Gregory Anders <greg@gpanders.com> | 2023-04-19 07:52:04 -0600 |
commit | 94894068794dbb99804cda689b6c37e70376c8ca (patch) | |
tree | 1dbfb55be2c53077e9318b6171b2113bf3628340 /scripts/genvimvim.lua | |
parent | 6b96122453fda22dc44a581af1d536988c1adf41 (diff) | |
download | rneovim-94894068794dbb99804cda689b6c37e70376c8ca.tar.gz rneovim-94894068794dbb99804cda689b6c37e70376c8ca.tar.bz2 rneovim-94894068794dbb99804cda689b6c37e70376c8ca.zip |
fix(iter): remove special case totable for map-like tables
This was originally meant as a convenience but prevents possible
functionality. For example:
-- Get the keys of the table with even values
local t = { a = 1, b = 2, c = 3, d = 4 }
vim.iter(t):map(function(k, v)
if v % 2 == 0 then return k end
end):totable()
The example above would not work, because the map() function returns
only a single value, and cannot be converted back into a table (there
are many such examples like this).
Instead, to convert an iterator into a map-like table, users can use
fold():
vim.iter(t):fold({}, function(t, k, v)
t[k] = v
return t
end)
Diffstat (limited to 'scripts/genvimvim.lua')
0 files changed, 0 insertions, 0 deletions