[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Return a variable number of values from function
- From: Siome Klein Goldenstein <siome@...>
- Date: Sun, 18 Nov 2001 17:40:46 -0500
On Sun, Nov 18, 2001 at 11:38:50PM +0100, Matthias Gall wrote:
> > function foo()
> > return 6, "hello", {}, 32
> > end
> >
> > local a, b, c, d = foo()
> >
> > Steve
>
> Thank you, Steve. Unfortunately, this is not a variable number of return
> values. I am searching for a way to return one time 1, another time 2, ...,
> or even 100 values without a need to bother about the size of the
> destination.
>
> Some pseudo code:
> Result = Foo()
> NumValues = sizeof(Result)
> FirstValue = Result[0]
> LastValue = Result[NumValues-1]
>
> Is something like this possible in LUA?
>
> Greetings,
> Matt
function foo ()
return {6, "hello", {}, 32}
end
Result = foo()
NumValues = getn(Result)
FirstValue = Result[1]
LastValue = Result[NumValues]
--
----------------------------
Siome Klein Goldenstein
siome@cis.upenn.edu
http://www.cis.upenn.edu/~siome