mirror of
https://github.com/TangentFoxy/lume.git
synced 2024-12-13 17:24:21 +00:00
Removed retainkeys
argument from lume.set()
This commit is contained in:
parent
756d30416d
commit
c773acdcf4
@ -135,10 +135,8 @@ an error is raised,
|
|||||||
lume.reduce({1, 2, 3}, function(a, b) return a + b end) -- Returns 6
|
lume.reduce({1, 2, 3}, function(a, b) return a + b end) -- Returns 6
|
||||||
```
|
```
|
||||||
|
|
||||||
### lume.set(t [, retainkeys])
|
### lume.set(t)
|
||||||
Returns a copy of the `t` table with all the duplicate values removed. If
|
Returns a copy of the `t` array with all the duplicate values removed.
|
||||||
`retainkeys` is true the table is not treated as an array and retains its
|
|
||||||
original keys.
|
|
||||||
```lua
|
```lua
|
||||||
lume.set({2, 1, 2, "cat", "cat"}) -- Returns {1, 2, "cat"}
|
lume.set({2, 1, 2, "cat", "cat"}) -- Returns {1, 2, "cat"}
|
||||||
```
|
```
|
||||||
|
4
lume.lua
4
lume.lua
@ -232,10 +232,10 @@ function lume.reduce(t, fn, first)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function lume.set(t, retainkeys)
|
function lume.set(t)
|
||||||
local rtn = {}
|
local rtn = {}
|
||||||
for k, v in pairs(lume.invert(t)) do
|
for k, v in pairs(lume.invert(t)) do
|
||||||
rtn[retainkeys and v or (#rtn + 1)] = k
|
rtn[#rtn + 1] = k
|
||||||
end
|
end
|
||||||
return rtn
|
return rtn
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user