3

I'm studying the class demo, you can find here https://www.lua.org/cgi-bin/demo?account. In Programming in Lua they create a new account with this line:

 a = Account:new{balance = 0}  -- (1)

it seems the same as a normal function call as this:

a = Account:new({balance = 0})  -- (2)

I understand how the second call works, but can somebody explain me why the syntax in example 1 works?

Reine Elemente
  • 131
  • 1
  • 11

1 Answers1

1

The first form is just synctatic sugar for the second form.

See section 3.4.10 of the reference manual.

lhf
  • 70,581
  • 9
  • 108
  • 149