---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by 10169.
--- DateTime: 2021/8/13 14:39
---

a = 100;

-- IF 判断
print("IF 判断逻辑开始 --------------------------")
if (a < 20)
then
    print("a 小于 20")
else
    print("a 大于 20")
end
print("a 的值为 :", a)


-- For 循环 : 从 1 变化到 f(5) , 每次变化 2
function f(x)
    print("function")
    return x * 2
end
print("FOR 逻辑开始 --------------------------")
for i = 1, f(5), 2 do
    print(i)
end

-- 泛型 For 循环 (ForEach)
print("FOR Demo2 逻辑开始 --------------------------")
days = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }
for i, v in ipairs(days) do
    print("这是打印结果 - index :", i, "- value : ", v)
end

print("While 循环 逻辑开始 --------------------------")
num = 10
while (num < 20)
do
    print("a 的值为:", num)
    num = num + 1
end

print("While 循环 Break 逻辑开始 --------------------------")
num = 10
while (num < 20)
do
    print("a 的值为:", num)
    if (num == 15) then
        break
    end
    num = num + 1
end

print("Lua repeat...until 循环 Break 逻辑开始(do-while) --------------------------")
a = 10
repeat
    print("a的值为:", a)
    a = a + 1
until (a > 13)


print("Lua table(表) --------------------------")
mytable = {}
mytable[1]= "Lua"
mytable["wow"] = "修改前"

print(mytable[1])
print(mytable["wow"])

mytable["wow"] = "修改后"
print(mytable["wow"])

mytable = nil
print("alternatetable 是 ", mytable)

