lua-users home
lua-l archive

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


function pack( ... )
	return { n = select( '#', ... ), ... }
end

The results of this need to be used as unpack( packed, 1, packed.n ).

Mark

On Jan 17, 2010, at 2:29 AM, Majic wrote:

> Hello, I've been trying to figure out the best way, or if there's a
> shorthand way, to build a table from whatever is returned by a
> function.  I was thinking something along the lines of local newtable
> = pack(somefunc())  I know pack() doesn't exist, but I can't seem to
> get anything similar if I were to do local newtable{} = somefunc()?  I
> vaguely remember someone doing something like this, I just don't know
> the syntax, or I'm imagining things again... Anyway, I thought it was
> very strange that a pack() doesn't exist and in another message on
> here I suggested that unpack() be moved to table.unpack() anyway
> (sort of wish this and that posting were together now...)  I just
> thought it'd be useful...
> 
> 
> Ideas?
>