Explain this syntax...

I’m reading through the documentation for the button widget and I noticed this syntax

widget.newButton{id="", label=""...}

I’m guessing this is calling a method of widget and passing a table. I’m new to Lua so this is a little strange to me. I would think of more like

widget.newButton({id=""...})

What if I wanted to write my own functions that received a table in this way. What does the function definition look like for this?

What if you had a table in a variable what would the syntax be? For example:

local t = {id=""...} 
widget.newButton[t]??

[import]uid: 98652 topic_id: 19177 reply_id: 319177[/import]

its because newButton function probably looks like this:
[lua]function newButton( params )

local x = params.x
local y = params.y
local imageName = params.name

local image = display.newImage(imageName)
image.x = x
image.y = y

return image
end[/lua]

its all because of the one “params” for function arguments [import]uid: 16142 topic_id: 19177 reply_id: 73988[/import]

I guess from what I’m used to I’d expect some parenthesis:

function newButton(params)
...
end

newButton( {...} )

So there’s really no mystery here, just quirk or shortcut of syntax. [import]uid: 98652 topic_id: 19177 reply_id: 73995[/import]