Skip to content

Commit b8dff01

Browse files
committed
table.invert
1 parent 345532a commit b8dff01

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/Runtime Environment/Table.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,21 @@ local t = {
305305
print(dumpvar(t:chunk(3))) -- { { 1, 2, 3 }, { "hello", "world" } }
306306
```
307307
---
308+
### `table.invert`
309+
Generates a new table with an inverse key-value relationship to the input table.
310+
#### Parameters
311+
1. The table.
312+
```pluto
313+
local t = {
314+
["key1"] = "value1",
315+
["key2"] = "value2",
316+
"foo",
317+
"bar"
318+
}
319+
320+
print(dumpvar(t:invert())) -- { value1 = "key1", value2 = "key2", foo = 1, bar = 2 }
321+
```
322+
---
308323
### `table.back`
309324
Returns the last element of a table. This is functionally identical to `t[#t]`.
310325
#### Parameters

0 commit comments

Comments
 (0)