user3313535
user3313535

Reputation: 25

Creating 2d string indexed tables in Lua

I need to create a table like:

M = {"A"={"a1"=0, "a2"= 1}, "B"={"b1"=2,"b2"=3}}

but this is what I got: " '}' expected near '=' "

Is there anyway to do/simulate this?

Upvotes: 1

Views: 136

Answers (1)

Yu Hao
Yu Hao

Reputation: 122383

foo.bar is the syntactic sugar of foo["bar"], there are no double quotes in the the former syntax:

M = {A = {a1 = 0, a2 = 1}, B = {b1 = 2, b2 =3 }}

Upvotes: 2

Related Questions