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

我有以下代码:

function output( string )
   print( string )
end

output 'Hola!' -- 为什么我这里不需要使用 `(` 和 `)`?

Lua 语言中,在什么情况下我不需要使用 (

点赞
用户621962
用户621962

请参阅文档

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

    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({})
2014-04-04 20:42:14