◆関数
--基本
function f(_arg)
print(_arg)
end
f("Hello World")
f2 = function()
print("Hello World2")
end
f2()
--数の合わない引数
function fu(_arg1, _arg2)
print("_arg1:", _arg1)
print("_arg2:", _arg2)
end
fu("Hello")
fu("Hello", "World")
fu("Hello", "World", "Hi")
--可変長引数
function fun(...)
args = {...}
for index, value in ipairs(args) do
print(index, ":", value)
end
end
fun("Hello", "World")
0 件のコメント:
コメントを投稿