mirror of
https://github.com/nanotee/nvim-lua-guide
synced 2024-11-15 06:13:00 +00:00
Update _G.dump()
This modifies code of `_G.dump()` to make it more explicit with `nil` values. Now `dump(nil)` will print `nil` instead of not doing anything. This also changes printing of multiple arguments: it will print on separate lines instead of separated with spaces.
This commit is contained in:
parent
13af62882a
commit
f5672b5ded
11
README.md
11
README.md
@ -408,9 +408,14 @@ Writing `print(vim.inspect(x))` every time you want to inspect the contents of a
|
||||
|
||||
```lua
|
||||
function _G.dump(...)
|
||||
local objects = vim.tbl_map(vim.inspect, {...})
|
||||
print(unpack(objects))
|
||||
return ...
|
||||
local objects, v = {}, nil
|
||||
for i = 1, select('#', ...) do
|
||||
v = select(i, ...)
|
||||
table.insert(objects, vim.inspect(v))
|
||||
end
|
||||
|
||||
print(table.concat(objects, '\n'))
|
||||
return ...
|
||||
end
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user