lua-users home
lua-l archive

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


Hi,

is it possible to get the name of a variable within Lua if I only have
the variable?  I want to write a small helper function logger that
basically prints the name and the value of the variable

function logger(name, value) print(name, 'has value', value) end
foo = 'hello'
logger('foo', foo)

Now I'd like to just call "logger(foo)" and get the same output.

</nk>