【发布时间】:2017-11-05 09:51:09
【问题描述】:
由于某种原因,似乎返回的国家都是成对返回的?如何更改代码使其仅返回“欧洲”中的国家/地区一次?
function newcountry(continent,country)
local object = {}
object.continent = continent
object.country = country
local list = {}
for i in pairs( object ) do
if object.continent == "Europe" then
table.insert(list, object.country)
print(object.country)
end
end
return object
end
a = newcountry("Africa","Algeria")
b = newcountry("Europe","England")
c = newcountry("Europe","France")
d = newcountry("Europe","Spain")
e = newcountry("Asia","China")
【问题讨论】:
标签: arrays class printing lua lua-table