Call as
Functions.collections.tomap(array)
Record it as a dependency named Functions.collections.tomap (accepting the completion does this), then call it by that name.
What it does
Copy a table using tostring of each original key as the destination key. Values retain their original identities. Colliding stringified keys overwrite each other in unspecified pairs traversal order.
Arguments
| Name | Type | What it does |
|---|---|---|
array | table | Table whose keys should be converted to strings. |
Returns
| 1 | table | New table with stringified keys and unchanged values. |
|---|
Editions
Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.
It reads no game API directly.
Example
local byID = Functions.collections.tomap({ [774] = "Rejuvenation", [8936] = "Regrowth" })
return byID["774"] == "Rejuvenation"Source
Functions/collections.lua, line 64. Read only in game; Duplicate makes an editable copy.
Functions.collections.tomap(array)
local rv = {}
for k,v in pairs(array) do
rv[tostring(k)] = v
end
return rv