lua-users home
lua-l archive

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

Given a function that returns multiple values, is there a way to construct a table, but where each value is assigned a name rather than an index

The effect I'm looking for is

> local date = {}
>, date.month, date.year = startdate:match("(%d%d)/(%d%d)/(%d%d%d%d)")
> print(os.time(date))

But without declaring the local date.


> print(os.time({startdate:match("(%d%d)/(%d%d)/(%d%d%d%d)")}))

doesn't work because the values are assign to indices 1, 2, and 3

Nor does

> print(os.time({day, month, year = startdate:match("(%d%d)/(%d%d)/(%d%d%d%d)")}))

because it interprets day and month as values rather than keys.