[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Chaining methods
- From: Pavel <temp213@...>
- Date: Mon, 17 Feb 2020 03:21:01 -0700 (MST)
Sure, it just looks a bit ugly when you have Lua based DSL and only such a
tables and still have to declare all of them like that. Global single
character function not the most beautiful thing.
Sam Putman wrote
> On Sun, Feb 16, 2020 at 4:52 PM Pavel <
> temp213@
> > wrote:
> `t()` is one more character than `{}` and could be defined like so:
>
> local function t(tab) -- can be global in a long/complex program
> tab = tab or {}
> return setmetatable({}, table)
> end
>
> and you could call it with `t{}` to remind yourself what it does.
>
> This is what I'd do if I were planning to use such tables frequently.
>
> cheers,
> -Sam.
--
Sent from: http://lua.2524044.n2.nabble.com/Lua-l-f2524044.html