lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Is there any way to reference a nested element of a table given a string
reference to it? That is, given some simple data like this:

foo = {a=1, b=2, c={d=3}}

Could you have a function like this (I know this function doesn't work):
function GetElement(table, field)
	return table[field]
such that with the above data GetElement(foo, "c.d") returns 3?