Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use ')' when calling a function?

Tags:

lua

I have the code:

function output( string )
   print( string )
end

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

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

like image 536
user3499641 Avatar asked Mar 19 '23 23:03

user3499641


1 Answers

Check the documentation:

If the function has one single argument and this argument is either a literal string or a table constructor, then the parentheses 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({})
like image 65
canon Avatar answered Apr 28 '23 18:04

canon