Basit bir lua programlama örneği:
occupants = {"Jones","Smith","Patel","Brown","Ng"}
occupants[1] = "Roberts"
occupants[6] = "Lee"
occupants[9] = "Forsythe"
occupants[8] = "Campbell"
occupants["llareggub"] = "Thomas"
-- indexed section - sequential from start
for dis,dat in ipairs(occupants) do
print (dis .. " - " .. dat)
end
-- whole thing
for dis,dat in pairs(occupants) do
print (dis .. " > " .. dat)
end
--[[ Sample output --------------------------------
[trainee@easterton nts]$ lua clike
1 - Roberts
2 - Smith
3 - Patel
4 - Brown
5 - Ng
6 - Lee
1 > Roberts
2 > Smith
3 > Patel
4 > Brown
5 > Ng
6 > Lee
8 > Campbell
9 > Forsythe
llareggub > Thomas
[trainee@easterton nts]$
]]
Hiç yorum yok:
Yorum Gönder