[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [PUZZLE] Appending to a list
- From: Martin <eden_martin_fuhrspam@...>
- Date: Sat, 9 Sep 2017 00:53:47 +0100
On 09/08/2017 08:03 AM, Dirk Laurie wrote:
> Almost that: I called something like
>
> append(t, myfunc(...))
>
> where myfunc has nice explicit return statements returning one value,
> except when none of them has been hit, so that at the end of the function
> it returns nothing.
>
You may call "table.insert(t, (myfunc(...)))" with same results.
Lua 5.3.4 Copyright (C) 1994-2017 Lua.org, PUC-Rio
> f = function() return end
> g = function() return nil end
> f()
> g()
nil
> (f())
nil
> t = {}
> table.insert(t, f())
stdin:1: wrong number of arguments to 'insert'
stack traceback:
[C]: in function 'table.insert'
stdin:1: in main chunk
[C]: in ?
> table.insert(t, (f()))
-- Martin