mirror of
https://github.com/TangentFoxy/lume.git
synced 2024-11-19 07:04:24 +00:00
Changed lume.clear() to return the table, updated doc & tests
This commit is contained in:
parent
0a84bcd0d6
commit
d2b26fa681
@ -91,7 +91,8 @@ lume.remove(t, 2) -- `t` becomes { 1, 3 }
|
|||||||
```
|
```
|
||||||
|
|
||||||
### lume.clear(t)
|
### lume.clear(t)
|
||||||
Nils all the values in the table `t`, this renders the table empty.
|
Nils all the values in the table `t`, this renders the table empty. Returns
|
||||||
|
`t`.
|
||||||
```lua
|
```lua
|
||||||
local t = { 1, 2, 3 }
|
local t = { 1, 2, 3 }
|
||||||
lume.clear(t) -- `t` becomes {}
|
lume.clear(t) -- `t` becomes {}
|
||||||
|
1
lume.lua
1
lume.lua
@ -180,6 +180,7 @@ function lume.clear(t)
|
|||||||
for k, v in iter(t) do
|
for k, v in iter(t) do
|
||||||
t[k] = nil
|
t[k] = nil
|
||||||
end
|
end
|
||||||
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -142,6 +142,7 @@ tests["lume.clear"] = function()
|
|||||||
local m = { a = 1, b = 2, c = 3 }
|
local m = { a = 1, b = 2, c = 3 }
|
||||||
lume.clear(m)
|
lume.clear(m)
|
||||||
testeq(m, {})
|
testeq(m, {})
|
||||||
|
testeq( lume.clear(t) == t, true )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- lume.shuffle
|
-- lume.shuffle
|
||||||
|
Loading…
Reference in New Issue
Block a user