为什么在调用函数时使用')'?

时间:2014-04-04 20:39:35

标签: lua

我有代码:

function output( string )
   print( string )
end

output 'Hola!' -- Why do I not need `(` and `)` here?

我什么时候不需要使用(语言中的Lua

1 个答案:

答案 0 :(得分:7)

检查the documentation

  

如果函数只有一个参数,并且该参数是文字字符串或表构造函数,则括号是可选的:

    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({})