Why use ')' when calling a function?

I have a code:

function output( string )
   print( string )
end

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

When I do not need to use (the language Lua.

+4
source share
1 answer

Check the documentation :

If the function has one single argument, and this argument is either a literal string or a table constructor, then the brackets are optional:

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

Source: https://habr.com/ru/post/1535098/


All Articles