Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Semrush - keyword research tool

Create your online store today with Shopify

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Disclosure: My content contains affiliate links.

43,226 questions

56,128 answers

573 users

How to merge dictionaries in Lua

1 Answer

0 votes
local dict1 = {
    ["lua"] = 3, 
    ["c"] = 9,
    ["java"] = 4,
    python = 6
}

local dict2 = {release = 5.4, base = "ANSI C", start = 1993}

mergedDict = {}
for key, val in pairs(dict1) do
    mergedDict[key] = val
end

for key, val in pairs(dict2) do
    mergedDict[key] = val
end

for key, val in pairs(mergedDict ) do
    print(string.format("%s: %s", key, val))
end





--[[
run:

python: 6
java: 4
lua: 3
c: 9
base: ANSI C
release: 5.4
start: 1993

--]]

 



answered Dec 14, 2022 by avibootz

Related questions

1 answer 207 views
207 views asked May 19, 2025 by avibootz
2 answers 288 views
2 answers 271 views
1 answer 234 views
234 views asked Feb 15, 2023 by avibootz
1 answer 210 views
210 views asked Feb 15, 2023 by avibootz
1 answer 251 views
1 answer 267 views
...