我有代码:
function output( string )
print( string )
end
output 'Hola!' -- Why do I not need `(` and `)` here?
我什么时候不需要使用(
语言中的Lua
。
答案 0 :(得分:7)
如果函数只有一个参数,并且该参数是文字字符串或表构造函数,则括号是可选的:
print "Hello World" print("Hello World") dofile 'a.lua' dofile ('a.lua') print [[a multi-line print([[a multi-line message]] message]]) f{x=10, y=20} f({x=10, y=20}) type{} type({})