RosettaCodeData/Task/Associative-array-Iteration/Lua/associative-array-iteration.lua

14 lines
345 B
Lua
Raw Permalink Normal View History

2026-02-01 16:33:20 -08:00
local function f1(x) print(x) return x end
local t = { ["foo"] = "bar"
, ["baz"] = 6
, fortytwo = 7
, [42] = { 1, 2, 3 }
, [f1] = true
, ["zz"] = f1
}
2023-07-01 11:58:00 -04:00
for key,val in pairs(t) do
2026-02-01 16:33:20 -08:00
print(string.format("%28s (%9s) -> (%9s) %s", key, type(key), type(val), val))
2023-07-01 11:58:00 -04:00
end